Permalink
Browse files

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

…ls 3.0.x.
  • Loading branch information...
cmeiklejohn authored and tenderlove committed Jul 30, 2011
1 parent ebfad37 commit 55eadccfbf5fa92593f3f4884225c46c5575e26b
@@ -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

0 comments on commit 55eadcc

Please sign in to comment.