diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2013-03-16 16:41:14 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2013-03-22 16:22:01 -0700 |
commit | 739a72036162b4057ceb4de6950624c0c0ed93b4 (patch) | |
tree | 377a49203384f7c5ff6d2eaaf15432e6bb9fbd9c /activerecord | |
parent | 072dbbf2aeb2be4f074ba8e404ee157f281bedf9 (diff) | |
download | rails-739a72036162b4057ceb4de6950624c0c0ed93b4.tar.gz rails-739a72036162b4057ceb4de6950624c0c0ed93b4.tar.bz2 rails-739a72036162b4057ceb4de6950624c0c0ed93b4.zip |
allow multiple add columns
Diffstat (limited to 'activerecord')
3 files changed, 6 insertions, 6 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb index 7f0be28080..962c63effd 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb @@ -292,11 +292,11 @@ module ActiveRecord end class AlterTable # :nodoc: - attr_reader :add + attr_reader :adds def initialize(td) - @td = td - @add = nil + @td = td + @adds = [] end def name; @td.name; end @@ -304,7 +304,7 @@ module ActiveRecord def add_column(name, type, options) name = name.to_s type = type.to_sym - @add = @td.new_column_definition(name, type, options) + @adds << @td.new_column_definition(name, type, options) end end diff --git a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb index 5d38b45a5b..3dc284b4ce 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb @@ -116,7 +116,7 @@ module ActiveRecord def visit_AlterTable(o) sql = "ALTER TABLE #{quote_table_name(o.name)} " - if col = o.add + o.adds.each do |col| sql_type = type_to_sql(col.type.to_sym, col.limit, col.precision, col.scale) sql << "ADD #{quote_column_name(col.name)} #{sql_type}" add_column_options!(sql, column_options(col)) diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb index 28c5209ad4..df2315d0ff 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb @@ -7,7 +7,7 @@ module ActiveRecord def visit_AlterTable(o) sql = "ALTER TABLE #{quote_table_name(o.name)} " - if col = o.add + o.adds.each do |col| sql_type = type_to_sql(col.type.to_sym, col.limit, col.precision, col.scale) sql << "ADD COLUMN #{quote_column_name(col.name)} #{sql_type}" add_column_options!(sql, column_options(col)) |