aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/invertible_migration_test.rb
diff options
context:
space:
mode:
authorMarc-Andre Lafortune <github@marc-andre.ca>2012-08-06 20:44:05 -0400
committerMarc-Andre Lafortune <github@marc-andre.ca>2012-12-21 13:54:51 -0500
commitd327c1805a58641a15d76e5e7de2f3fa1c0b9d03 (patch)
tree0b486628402e22288afa775ee92b15cf6c68fdfa /activerecord/test/cases/invertible_migration_test.rb
parent740dbf8d42f6bef86845086690ac522cf91ceece (diff)
downloadrails-d327c1805a58641a15d76e5e7de2f3fa1c0b9d03.tar.gz
rails-d327c1805a58641a15d76e5e7de2f3fa1c0b9d03.tar.bz2
rails-d327c1805a58641a15d76e5e7de2f3fa1c0b9d03.zip
Allow reverting of migration commands with Migration#revert [#8267]
Diffstat (limited to 'activerecord/test/cases/invertible_migration_test.rb')
-rw-r--r--activerecord/test/cases/invertible_migration_test.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/activerecord/test/cases/invertible_migration_test.rb b/activerecord/test/cases/invertible_migration_test.rb
index 8f1cdd47ea..6d285e23d7 100644
--- a/activerecord/test/cases/invertible_migration_test.rb
+++ b/activerecord/test/cases/invertible_migration_test.rb
@@ -17,6 +17,17 @@ module ActiveRecord
end
end
+ class InvertibleRevertMigration < SilentMigration
+ def change
+ revert do
+ create_table("horses") do |t|
+ t.column :content, :text
+ t.column :remind_at, :datetime
+ end
+ end
+ end
+ end
+
class NonInvertibleMigration < SilentMigration
def change
create_table("horses") do |t|
@@ -67,6 +78,18 @@ module ActiveRecord
assert !migration.connection.table_exists?("horses")
end
+ def test_migrate_revert
+ migration = InvertibleMigration.new
+ revert = InvertibleRevertMigration.new
+ migration.migrate :up
+ revert.migrate :up
+ assert !migration.connection.table_exists?("horses")
+ revert.migrate :down
+ assert migration.connection.table_exists?("horses")
+ 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"