From 47a3bafe26fb5f773ac082162c3e595ce80d9ad7 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sat, 9 Jul 2005 15:46:29 +0000 Subject: Added a VERSION parameter to the migrate task that allows you to do "rake migrate VERSION=34" to migrate to the 34th version traveling up or down depending on the current version. Added ActiveRecord::Migrator.migrate that can figure out whether to go up or down based on the target version and the current git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1780 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activerecord/test/migration_test.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'activerecord/test') diff --git a/activerecord/test/migration_test.rb b/activerecord/test/migration_test.rb index 9e84978395..d5081e5335 100644 --- a/activerecord/test/migration_test.rb +++ b/activerecord/test/migration_test.rb @@ -182,5 +182,20 @@ if ActiveRecord::Base.connection.supports_migrations? assert !Person.column_methods_hash.include?(:last_name) assert_raises(ActiveRecord::StatementInvalid) { Reminder.column_methods_hash } end + + def test_migrator_going_down_due_to_version_target + ActiveRecord::Migrator.up(File.dirname(__FILE__) + '/fixtures/migrations/', 1) + ActiveRecord::Migrator.migrate(File.dirname(__FILE__) + '/fixtures/migrations/', 0) + + assert !Person.column_methods_hash.include?(:last_name) + assert_raises(ActiveRecord::StatementInvalid) { Reminder.column_methods_hash } + + ActiveRecord::Migrator.migrate(File.dirname(__FILE__) + '/fixtures/migrations/') + + Person.reset_column_information + assert Person.column_methods_hash.include?(:last_name) + assert Reminder.create("content" => "hello world", "remind_at" => Time.now) + assert_equal "hello world", Reminder.find(:first).content + end end end \ No newline at end of file -- cgit v1.2.3