- Timestamp:
- 09/09/07 05:40:34 (1 year ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/railties/lib/rails_generator/generators/components/migration/USAGE
r7216 r7422 1 1 Description: 2 2 Stubs out a new database migration. Pass the migration name, either 3 CamelCased or under_scored, as an argument. A migration class is generated 4 in db/migrate prefixed by the latest migration number. 3 CamelCased or under_scored, and an optional list of attribute pairs as arguments. 4 5 A migration class is generated in db/migrate prefixed by the latest migration number. 5 6 6 7 You can name your migration in either of these formats to generate add/remove 7 column lines : AddColumnToTable or RemoveColumnFromTable8 column lines from supplied attributes: AddColumnsToTable or RemoveColumnsFromTable 8 9 9 10 Example: … … 13 14 db/migrate/005_add_ssl_flag.rb 14 15 15 `./script/generate migration Add SslFlagToAccount`16 `./script/generate migration AddTitleBodyToPost title:string body:text published:boolean` 16 17 17 This will create the Add SslFlagToAccount in db/migrate/005_add_ssl_flag_to_account.rb with18 This will create the AddTitleBodyToPost in db/migrate/005_add_title_body_to_post.rb with 18 19 this in the Up migration: 19 20 20 add_column :accounts, :ssl_flag, :type, :null => :no?, :default => :maybe? 21 add_column :posts, :title, :string 22 add_column :posts, :body, :text 23 add_column :posts, :published, :boolean 21 24 22 25 And this in the Down migration: 23 26 24 remove_column :accounts, :ssl_flag 27 remove_column :posts, :published 28 remove_column :posts, :body 29 remove_column :posts, :title