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 148 | Next

Kevin Marshall, Chad Pytel, and Jon Yurek

"Pro Active Record: Databases with Ruby and Rails"

This method
actually takes an options hash, but it doesn??™t use anything in there as of this writing. Simply
pass it the name of the table you want to drop, and it??™s dropped.
def self.down
drop_table :cows
end
It??™s that simple. Now, migrating from zero to the most current schema, as defined by our
most recent migration script, and back will keep our database in a consistent state, as shown
following:
mysql> show tables;
+-----------------------------+
| Tables_in_test2_development |
+-----------------------------+
| schema_info |
+-----------------------------+
Adding, Removing, and Changing Database Columns
There??™s more to migrations than simply creating and dropping tables. They let you deal with
any part of database management in an abstract way. If you look at our previous cows table,
you may notice that we forgot to add the farmer_id column. Since a Cow belongs to a Farmer,
the foreign key farmer_id is an important field. What??™s more, we??™ve already committed the
migration to source control, so we should assume that someone else has already run it.


Pages:
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6