Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

activerecord: Initialize Migration with version from MigrationProxy.

  • Loading branch information...
commit 06ace1e2b5cdccf67ff969ff0d355fd87f46dcf0 1 parent f2b80a4
@dylanahsmith dylanahsmith authored
View
5 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.
View
2  activerecord/lib/active_record/migration.rb
@@ -759,7 +759,7 @@ def migration
def load_migration
require(File.expand_path(filename))
- name.constantize.new
+ name.constantize.new(name, version)
end
end
View
4 activerecord/test/cases/migration_test.rb
@@ -79,6 +79,10 @@ def test_migrator_versions
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
View
8 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
Please sign in to comment.
Something went wrong with that request. Please try again.