Let’s say I used the following command to create a “User” model:
script/generate model User username:string
This creates the user.rb file along with the migration rb file to create the Users table. Now, I want to add an email column to my User model. What’s the best way to do that? Do I do it manually and write the migration file by hand or is there a shortcut for doing it? If I write the migration by hand, do I have to name it the same way as the previous migration script (with a timestamp in front) to guarantee that it runs after the previous migration?
Don’t worry about the timestamp. It will be generated automatically.
You can do a
This would automatically create a migration file which would look like this:
the file would have the timestamp in the format
YYYYMMDDHHMMSS(For Rails 2.1 and above) appended in front of the filename.