From 06ace1e2b5cdccf67ff969ff0d355fd87f46dcf0 Mon Sep 17 00:00:00 2001 From: Dylan Thacker-Smith Date: Tue, 17 Dec 2013 16:02:52 -0500 Subject: activerecord: Initialize Migration with version from MigrationProxy. --- activerecord/CHANGELOG.md | 5 +++++ activerecord/lib/active_record/migration.rb | 2 +- activerecord/test/cases/migration_test.rb | 4 ++++ .../version_check/20131219224947_migration_version_check.rb | 8 ++++++++ 4 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 activerecord/test/migrations/version_check/20131219224947_migration_version_check.rb diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md index efe29fbc88..0d93cb0545 100644 --- a/activerecord/CHANGELOG.md +++ b/activerecord/CHANGELOG.md @@ -1,3 +1,8 @@ +* Initialize version on Migration objects so that it can be used in a migration, + and it will be included in the announce message. + + *Dylan Thacker-Smith* + * Fixed ActiveRecord::Store nil conversion TypeError when using YAML coder. In case the YAML passed as paramter is nil, uses an empty string. diff --git a/activerecord/lib/active_record/migration.rb b/activerecord/lib/active_record/migration.rb index fc84b907a5..b57da73969 100644 --- a/activerecord/lib/active_record/migration.rb +++ b/activerecord/lib/active_record/migration.rb @@ -759,7 +759,7 @@ module ActiveRecord def load_migration require(File.expand_path(filename)) - name.constantize.new + name.constantize.new(name, version) end end diff --git a/activerecord/test/cases/migration_test.rb b/activerecord/test/cases/migration_test.rb index ebcc778b8b..0363bf1048 100644 --- a/activerecord/test/cases/migration_test.rb +++ b/activerecord/test/cases/migration_test.rb @@ -79,6 +79,10 @@ class MigrationTest < ActiveRecord::TestCase ActiveRecord::Migrator.migrations_paths = old_path end + def test_migration_version + ActiveRecord::Migrator.run(:up, MIGRATIONS_ROOT + "/version_check", 20131219224947) + end + def test_create_table_with_force_true_does_not_drop_nonexisting_table if Person.connection.table_exists?(:testings2) Person.connection.drop_table :testings2 diff --git a/activerecord/test/migrations/version_check/20131219224947_migration_version_check.rb b/activerecord/test/migrations/version_check/20131219224947_migration_version_check.rb new file mode 100644 index 0000000000..9d46485a31 --- /dev/null +++ b/activerecord/test/migrations/version_check/20131219224947_migration_version_check.rb @@ -0,0 +1,8 @@ +class MigrationVersionCheck < ActiveRecord::Migration + def self.up + raise "incorrect migration version" unless version == 20131219224947 + end + + def self.down + end +end -- cgit v1.2.3