diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2008-03-28 21:21:01 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2008-03-28 21:21:01 +0000 |
commit | c00de99f69358b58ca2bd6bc732e2de1b667800e (patch) | |
tree | fd5d4855a64bb15a99494b7efdb62f4798321a52 /activerecord/test | |
parent | ad8df03f9c831d88b8a7eb80c1b7dbcf02fc1b19 (diff) | |
download | rails-c00de99f69358b58ca2bd6bc732e2de1b667800e.tar.gz rails-c00de99f69358b58ca2bd6bc732e2de1b667800e.tar.bz2 rails-c00de99f69358b58ca2bd6bc732e2de1b667800e.zip |
Switched to UTC-timebased version numbers for migrations and the schema. This will as good as eliminate the problem of multiple migrations getting the same version assigned in different branches. Also added rake db:migrate:up/down to apply individual migrations that may need to be run when you merge branches (closes #11458) [jbarnette]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9122 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/migration_test.rb | 43 |
1 files changed, 32 insertions, 11 deletions
diff --git a/activerecord/test/cases/migration_test.rb b/activerecord/test/cases/migration_test.rb index ebe563059d..75c939f24f 100644 --- a/activerecord/test/cases/migration_test.rb +++ b/activerecord/test/cases/migration_test.rb @@ -757,9 +757,9 @@ if ActiveRecord::Base.connection.supports_migrations? def test_migrator_one_down ActiveRecord::Migrator.up(MIGRATIONS_ROOT + "/valid") - + ActiveRecord::Migrator.down(MIGRATIONS_ROOT + "/valid", 1) - + Person.reset_column_information assert Person.column_methods_hash.include?(:last_name) assert !Reminder.table_exists? @@ -805,6 +805,33 @@ if ActiveRecord::Base.connection.supports_migrations? assert Reminder.create("content" => "hello world", "remind_at" => Time.now) assert_equal "hello world", Reminder.find(:first).content end + + def test_migrator_rollback + ActiveRecord::Migrator.migrate(MIGRATIONS_ROOT + "/valid") + assert_equal(3, ActiveRecord::Migrator.current_version) + + ActiveRecord::Migrator.rollback(MIGRATIONS_ROOT + "/valid") + assert_equal(2, ActiveRecord::Migrator.current_version) + + ActiveRecord::Migrator.rollback(MIGRATIONS_ROOT + "/valid") + assert_equal(1, ActiveRecord::Migrator.current_version) + + ActiveRecord::Migrator.rollback(MIGRATIONS_ROOT + "/valid") + assert_equal(0, ActiveRecord::Migrator.current_version) + + ActiveRecord::Migrator.rollback(MIGRATIONS_ROOT + "/valid") + assert_equal(0, ActiveRecord::Migrator.current_version) + end + + def test_migrator_run + assert_equal(0, ActiveRecord::Migrator.current_version) + ActiveRecord::Migrator.run(:up, MIGRATIONS_ROOT + "/valid", 3) + assert_equal(0, ActiveRecord::Migrator.current_version) + + assert_equal(0, ActiveRecord::Migrator.current_version) + ActiveRecord::Migrator.run(:down, MIGRATIONS_ROOT + "/valid", 3) + assert_equal(0, ActiveRecord::Migrator.current_version) + end def test_schema_info_table_name ActiveRecord::Base.table_name_prefix = "prefix_" @@ -892,15 +919,9 @@ if ActiveRecord::Base.connection.supports_migrations? end def test_migrator_with_missing_version_numbers - ActiveRecord::Migrator.migrate(MIGRATIONS_ROOT + "/missing", 500) - assert !Person.column_methods_hash.include?(:middle_name) - assert_equal 4, ActiveRecord::Migrator.current_version - - ActiveRecord::Migrator.migrate(MIGRATIONS_ROOT + "/missing", 2) - Person.reset_column_information - assert !Reminder.table_exists? - assert Person.column_methods_hash.include?(:last_name) - assert_equal 2, ActiveRecord::Migrator.current_version + assert_raise(ActiveRecord::UnknownMigrationVersionError) do + ActiveRecord::Migrator.migrate(MIGRATIONS_ROOT + "/missing", 500) + end end def test_create_table_with_custom_sequence_name |