Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

allow multiple add columns

  • Loading branch information...
commit 739a72036162b4057ceb4de6950624c0c0ed93b4 1 parent 072dbbf
@tenderlove tenderlove authored
View
8 activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
@@ -292,11 +292,11 @@ def native
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 @@ def name; @td.name; end
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
View
2  activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
@@ -116,7 +116,7 @@ def accept(o)
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))
View
2  activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb
@@ -7,7 +7,7 @@ class SchemaCreation < AbstractAdapter::SchemaCreation
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))
Please sign in to comment.
Something went wrong with that request. Please try again.