Description:
Stubs out a new database migration for ActiveRecord. Pass the migration name, either CamelCased or under_scored, and an optional list of attribute pairs as arguments. A migration class is generated in db/migrate prefixed by a timestamp of the current date and time. You can name your migration in either of these formats to generate add/remove column lines from supplied attributes: AddColumnsToTable or RemoveColumnsFromTable
Example:
`disco generate migration AddSslFlag` If the current date is May 14, 2008 and the current time 09:09:12, this creates the AddSslFlag migration db/migrate/20080514090912_add_ssl_flag.rb `disco generate migration AddSslFlag --domain` Under the same conditions as above, this creates the AddSslFlag migration db/migrate_domain/20080514090912_add_ssl_flag.rb `disco generate migration AddTitleBodyToPost title:string body:text published:boolean` This will create the AddTitleBodyToPost in db/migrate/20080514090912_add_title_body_to_post.rb with this in the Change migration: add_column :posts, :title, :string add_column :posts, :body, :text add_column :posts, :published, :boolean
Migration names containing JoinTable will generate join tables for use with has_and_belongs_to_many associations.
Example:
`disco g migration CreateMediaJoinTable artists musics:uniq` will create the migration create_join_table :artists, :musics do |t| # t.index [:artist_id, :music_id] t.index [:music_id, :artist_id], unique: true end