diff options
Diffstat (limited to 'railties/lib/rails_generator/generators/components/migration/USAGE')
-rw-r--r-- | railties/lib/rails_generator/generators/components/migration/USAGE | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/railties/lib/rails_generator/generators/components/migration/USAGE b/railties/lib/rails_generator/generators/components/migration/USAGE index c3f8ce0987..3e914a5d7b 100644 --- a/railties/lib/rails_generator/generators/components/migration/USAGE +++ b/railties/lib/rails_generator/generators/components/migration/USAGE @@ -1,10 +1,11 @@ Description: Stubs out a new database migration. Pass the migration name, either - CamelCased or under_scored, as an argument. A migration class is generated - in db/migrate prefixed by the latest migration number. + CamelCased or under_scored, and an optional list of attribute pairs as arguments. + + A migration class is generated in db/migrate prefixed by the latest migration number. You can name your migration in either of these formats to generate add/remove - column lines: AddColumnToTable or RemoveColumnFromTable + column lines from supplied attributes: AddColumnsToTable or RemoveColumnsFromTable Example: `./script/generate migration AddSslFlag` @@ -12,13 +13,17 @@ Example: With 4 existing migrations, this creates the AddSslFlag migration in db/migrate/005_add_ssl_flag.rb - `./script/generate migration AddSslFlagToAccount` + `./script/generate migration AddTitleBodyToPost title:string body:text published:boolean` - This will create the AddSslFlagToAccount in db/migrate/005_add_ssl_flag_to_account.rb with + This will create the AddTitleBodyToPost in db/migrate/005_add_title_body_to_post.rb with this in the Up migration: - add_column :accounts, :ssl_flag, :type, :null => :no?, :default => :maybe? + add_column :posts, :title, :string + add_column :posts, :body, :text + add_column :posts, :published, :boolean And this in the Down migration: - remove_column :accounts, :ssl_flag
\ No newline at end of file + remove_column :posts, :published + remove_column :posts, :body + remove_column :posts, :title |