mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Merge pull request #3477 from rud/stable-migrations-version-order-rebased
dump_schema_information: explicitly order inserts into schema_migrations
This commit is contained in:
@@ -405,7 +405,7 @@ module ActiveRecord
|
||||
|
||||
def dump_schema_information #:nodoc:
|
||||
sm_table = ActiveRecord::Migrator.schema_migrations_table_name
|
||||
migrated = select_values("SELECT version FROM #{sm_table}")
|
||||
migrated = select_values("SELECT version FROM #{sm_table} ORDER BY version")
|
||||
migrated.map { |v| "INSERT INTO #{sm_table} (version) VALUES ('#{v}');" }.join("\n\n")
|
||||
end
|
||||
|
||||
|
||||
@@ -1339,6 +1339,15 @@ if ActiveRecord::Base.connection.supports_migrations?
|
||||
end
|
||||
end
|
||||
|
||||
def test_dump_schema_information_outputs_lexically_ordered_versions
|
||||
migration_path = MIGRATIONS_ROOT + '/valid_with_timestamps'
|
||||
ActiveRecord::Migrator.run(:up, migration_path, 20100301010101)
|
||||
ActiveRecord::Migrator.run(:up, migration_path, 20100201010101)
|
||||
|
||||
schema_info = ActiveRecord::Base.connection.dump_schema_information
|
||||
assert_match schema_info, /20100201010101.*20100301010101/m
|
||||
end
|
||||
|
||||
def test_finds_pending_migrations
|
||||
ActiveRecord::Migrator.up(MIGRATIONS_ROOT + "/interleaved/pass_2", 1)
|
||||
migrations = ActiveRecord::Migrator.new(:up, MIGRATIONS_ROOT + "/interleaved/pass_2").pending_migrations
|
||||
|
||||
Reference in New Issue
Block a user