SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 141 | Next

Kevin Marshall, Chad Pytel, and Jon Yurek

"Pro Active Record: Databases with Ruby and Rails"


Stepping through your scripts will, instead, throw an error when older versions of your script can??™t find the
referenced class.
The Anatomy of aMigration File
Regardless of how you create your migration scripts (either via the Rails generate command or
simply by hand), they all should start out with a basic structure that looks something like the
following:
class CreateUsersTable < ActiveRecord::Migration
def self.up
end
def self.down
end
end
In this structure, the up method will get called when you??™re migrating up to the latest version
(i.e., when you are releasing new code and updates) and down will get called when you??™re
migrating down to a previous version (i.e., when you are rolling back because of unexpected
errors or problems).
The up and down methods are each run inside of a transaction. This means that if an
exception occurs during migration execution, the transaction will be rolled back, and the
schema_info version number will not be updated.
?– Caution At the time of this writing, MySQL could not successfully roll back ALTER TABLE statements, so
despite the fact that a migration is run in a transaction, if an exception occurs, the MySQL database will
likely be left in the state just prior to the occurrence of the exception.


Pages:
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6