Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Support backwards compatible interface for migration down/up with rai…

…ls 3.0.x.
  • Loading branch information...
commit 74d7bfb200e4590e244558554e147a31d30990df 1 parent 3a4dc9d
@cmeiklejohn cmeiklejohn authored tenderlove committed
View
1  activerecord/lib/active_record/migration.rb
@@ -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
View
24 activerecord/test/cases/invertible_migration_test.rb
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.