Permalink
Browse files

allow multiple add columns

  • Loading branch information...
1 parent 072dbbf commit 739a72036162b4057ceb4de6950624c0c0ed93b4 @tenderlove tenderlove committed Mar 16, 2013
@@ -292,19 +292,19 @@ 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
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
@@ -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))
@@ -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))

0 comments on commit 739a720

Please sign in to comment.