mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
parent
487145f871
commit
61bacd6ef9
2 changed files with 18 additions and 1 deletions
|
@ -394,7 +394,7 @@ module ActiveRecord
|
|||
end
|
||||
|
||||
def load_schema_if_pending!
|
||||
if ActiveRecord::Migrator.needs_migration?
|
||||
if ActiveRecord::Migrator.needs_migration? || !ActiveRecord::Migrator.any_migrations?
|
||||
ActiveRecord::Tasks::DatabaseTasks.load_schema_current
|
||||
check_pending!
|
||||
end
|
||||
|
@ -848,6 +848,10 @@ module ActiveRecord
|
|||
(migrations(migrations_paths).collect(&:version) - get_all_versions(connection)).size > 0
|
||||
end
|
||||
|
||||
def any_migrations?
|
||||
migrations(migrations_paths).any?
|
||||
end
|
||||
|
||||
def last_version
|
||||
last_migration.version
|
||||
end
|
||||
|
|
|
@ -100,6 +100,19 @@ class MigrationTest < ActiveRecord::TestCase
|
|||
ActiveRecord::Migrator.migrations_paths = old_path
|
||||
end
|
||||
|
||||
def test_any_migrations
|
||||
old_path = ActiveRecord::Migrator.migrations_paths
|
||||
ActiveRecord::Migrator.migrations_paths = MIGRATIONS_ROOT + "/valid"
|
||||
|
||||
assert ActiveRecord::Migrator.any_migrations?
|
||||
|
||||
ActiveRecord::Migrator.migrations_paths = MIGRATIONS_ROOT + "/empty"
|
||||
|
||||
assert_not ActiveRecord::Migrator.any_migrations?
|
||||
ensure
|
||||
ActiveRecord::Migrator.migrations_paths = old_path
|
||||
end
|
||||
|
||||
def test_migration_version
|
||||
ActiveRecord::Migrator.run(:up, MIGRATIONS_ROOT + "/version_check", 20131219224947)
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue