From 031605aa90fd6bbb706758cdf1a6e235f48c0ea7 Mon Sep 17 00:00:00 2001 From: Ryuta Kamizono Date: Sun, 5 Mar 2017 00:29:41 +0900 Subject: Fix `rake db:schema:load` with subdirectories Related #25174. `db:schema:load` doesn't work with subdirectories like previous `db:migrate:status`. `Migrator.migration_files` should be used in `assume_migrated_upto_version` to fix the issue. --- activerecord/test/cases/migrator_test.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'activerecord/test/cases') diff --git a/activerecord/test/cases/migrator_test.rb b/activerecord/test/cases/migrator_test.rb index 81f9749063..aadbc375af 100644 --- a/activerecord/test/cases/migrator_test.rb +++ b/activerecord/test/cases/migrator_test.rb @@ -152,6 +152,23 @@ class MigratorTest < ActiveRecord::TestCase ], ActiveRecord::Migrator.migrations_status(path) end + def test_migrations_status_with_schema_define_in_subdirectories + path = MIGRATIONS_ROOT + "/valid_with_subdirectories" + prev_paths = ActiveRecord::Migrator.migrations_paths + ActiveRecord::Migrator.migrations_paths = path + + ActiveRecord::Schema.define(version: 3) do + end + + assert_equal [ + ["up", "001", "Valid people have last names"], + ["up", "002", "We need reminders"], + ["up", "003", "Innocent jointable"], + ], ActiveRecord::Migrator.migrations_status(path) + ensure + ActiveRecord::Migrator.migrations_paths = prev_paths + end + def test_migrations_status_from_two_directories paths = [MIGRATIONS_ROOT + "/valid_with_timestamps", MIGRATIONS_ROOT + "/to_copy_with_timestamps"] -- cgit v1.2.3