提交 9d19bae2 编写于 作者: C Christopher Meiklejohn 提交者: Xavier Noria

Support backwards compatible interface for migration down/up with rails 3.0.x.

上级 8293b104
......@@ -329,6 +329,7 @@ class << self
end
def self.method_missing(name, *args, &block) # :nodoc:
self.delegate = self.new
(delegate || superclass.delegate).send(name, *args, &block)
end
......
......@@ -27,6 +27,19 @@ def change
end
end
class LegacyMigration < ActiveRecord::Migration
def self.up
create_table("horses") do |t|
t.column :content, :text
t.column :remind_at, :datetime
end
end
def self.down
drop_table("horses")
end
end
def teardown
if ActiveRecord::Base.connection.table_exists?("horses")
ActiveRecord::Base.connection.drop_table("horses")
......@@ -53,5 +66,16 @@ def test_down
migration.migrate :down
assert !migration.connection.table_exists?("horses")
end
def test_legacy_up
LegacyMigration.migrate :up
assert ActiveRecord::Base.connection.table_exists?("horses"), "horses should exist"
end
def test_legacy_down
LegacyMigration.migrate :up
LegacyMigration.migrate :down
assert !ActiveRecord::Base.connection.table_exists?("horses"), "horses should not exist"
end
end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册