mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Support backwards compatible interface for migration down/up with rails 3.0.x.
This commit is contained in:
committed by
Aaron Patterson
parent
3a4dc9d34c
commit
74d7bfb200
@@ -329,6 +329,7 @@ module ActiveRecord
|
||||
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 @@ module ActiveRecord
|
||||
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 @@ module ActiveRecord
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user