Migrations
  • Migration file names are specific. Must be sequence number "001_" plus the name of the class converted from camel-case to underscores.
  • Rails can infer some of the implementation for common migrations:
depot> rails generate migration add_quantity_to_line_item quantity:integer

Rails can tell from the name of the migration that you are adding one or more
columns to the line_items table, and can pick up the names and data types
for each column from the last argument. The two patterns that Rails matches
on is add_XXX_to_TABLE and remove_XXX_from_TABLE where the value of XXX is
ignored: what matters is the list of column names and types that appear after
the migration name.
  • Migration file names need to be alphanumeric with underscores. (had problem once where I used a '-' and got a weird error:
silver:~/Workspaces/ruby/citizen_volunteer jtigger$ rake db:migrate     
(in /Users/jtigger/Workspaces/ruby/citizen_volunteer)
rake aborted!
You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.first

(See full trace by running task with --trace)
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License