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

Kevin Marshall, Chad Pytel, and Jon Yurek

"Pro Active Record: Databases with Ruby and Rails"


Now that you??™ve provided the self.up method, it will be executed when we run rake
db:migrate from the command line. But what happens if you run rake db:migrate VERSION=0?
If you did that right now, the cows table would still be in the database, which isn??™t the state you
might expect it to be in. You might expect, naturally, that version zero of the database is completely
empty. That is what the self.down method is for. The self.down method should always
reverse the action performed in self.up.
CHAPTER 3 ?–  SETTING UP YOUR DATABASE 52
Of course, there will be times where a destructive action will have consequences that you
cannot reverse, such as the deletion of data. However, it??™s still best to think of migrations as
primarily maintaining the structure of the application??™s database, and therefore, self.down
should do its best to maintain structure both in forward and reverse. In this case, you need to
remove the table in the self.down method.
You can remove a table with the predictably named drop_table method.


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