To add 2 new cols to existing table in migration, we will have to do:
add_column :my_table, :col1, :string add_column :my_table, :col2, :string this will create 2 ALTER table statements. Alter table my_table add column col1 varchar(255) Alter table my_table add column col2 varchar(255) I don't know about all databases, but atleast MySQL doesn't seem to modify the table "in place". MySQL actually creates a new table, as copy of the old table with the specified modifications.Two separate statements would require MySQL to do that copy operation twice.so I am wondering can we add support for adding multiple columns to table using single ALTER TABLE? if yes, then I see following approches 1. Add support to accept multiple cols, in add_column[1] 2. Introduce a new method add_columns 3. Internal optimisation, if there are multiple add_column calls to same table in a migration, consolidate them & generate single ALTER TABLE statement. not sure if that is possible? If you any thoughts on this Performance Improvement Idea, let me know --Gaurish [1] http://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/SchemaStatements.html#method-i-add_column -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/rubyonrails-core. For more options, visit https://groups.google.com/d/optout.
