Skip to content

Commit

Permalink
Merge pull request #13355 from dylanahsmith/migration-version
Browse files Browse the repository at this point in the history
activerecord: Initialize Migration with version from MigrationProxy.

Conflicts:
	activerecord/CHANGELOG.md
  • Loading branch information
rafaelfranca committed Jan 7, 2014
2 parents 032ab50 + 06ace1e commit f124132
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
6 changes: 6 additions & 0 deletions activerecord/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
* 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*

* `change_table` now uses the current adapter's `update_table_definition`
method to retrieve a specific table definition.
This ensures that `change_table` and `create_table` will use
similar objects.

Fixes #13577 and #13503.

*Nishant Modak*, *Prathamesh Sonpatki*, *Rafael Mendonça França*
Expand Down
2 changes: 1 addition & 1 deletion activerecord/lib/active_record/migration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ def migration

def load_migration
require(File.expand_path(filename))
name.constantize.new
name.constantize.new(name, version)
end

end
Expand Down
4 changes: 4 additions & 0 deletions activerecord/test/cases/migration_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class MigrationVersionCheck < ActiveRecord::Migration
def self.up
raise "incorrect migration version" unless version == 20131219224947
end

def self.down
end
end

0 comments on commit f124132

Please sign in to comment.