lib/dm-migrations/sql/table_modifier.rb in dm-migrations-1.1.0.rc2 vs lib/dm-migrations/sql/table_modifier.rb in dm-migrations-1.1.0.rc3
- old
+ new
@@ -1,7 +1,9 @@
module SQL
class TableModifier
+ extend DataMapper::Property::Lookup
+
attr_accessor :table_name, :opts, :statements, :adapter
def initialize(adapter, table_name, opts = {}, &block)
@adapter = adapter
@table_name = table_name.to_s
@@ -34,11 +36,11 @@
# raise NotImplemented for SQLite3
@statements << "ALTER TABLE #{quoted_table_name} RENAME COLUMN #{quote_column_name(name)} TO #{quote_column_name(new_name)}"
end
def change_column(name, type, opts = {})
- # raise NotImplemented for SQLite3
- @statements << "ALTER TABLE #{quoted_table_name} ALTER COLUMN #{quote_column_name(name)} TYPE #{type}"
+ column = SQL::TableCreator::Column.new(@adapter, name, type, opts)
+ @statements << @adapter.change_column_type_statement(table_name, column)
end
def quote_column_name(name)
@adapter.send(:quote_name, name.to_s)
end