diff options
author | Britni Alexander <britnialexander@gmail.com> | 2018-07-27 14:38:50 -0400 |
---|---|---|
committer | Britni Alexander <britnialexander@gmail.com> | 2018-07-31 21:24:29 -0400 |
commit | e6173c98e8c150b96717133ef5807378a73c3ec1 (patch) | |
tree | 3bf9ecbfb3ba4a726eaddc5bc1e937bd6041500d | |
parent | fee7fba8934ee6005b7e8eefc4baf7db48f03934 (diff) | |
download | rails-e6173c98e8c150b96717133ef5807378a73c3ec1.tar.gz rails-e6173c98e8c150b96717133ef5807378a73c3ec1.tar.bz2 rails-e6173c98e8c150b96717133ef5807378a73c3ec1.zip |
use load_schema instead of migrate for parallel testing
-rw-r--r-- | activerecord/lib/active_record/tasks/database_tasks.rb | 3 | ||||
-rw-r--r-- | activerecord/lib/active_record/test_databases.rb | 12 |
2 files changed, 9 insertions, 6 deletions
diff --git a/activerecord/lib/active_record/tasks/database_tasks.rb b/activerecord/lib/active_record/tasks/database_tasks.rb index 521375954b..d943796024 100644 --- a/activerecord/lib/active_record/tasks/database_tasks.rb +++ b/activerecord/lib/active_record/tasks/database_tasks.rb @@ -248,6 +248,7 @@ module ActiveRecord def load_schema(configuration, format = ActiveRecord::Base.schema_format, file = nil, environment = env, spec_name = "primary") # :nodoc: file ||= dump_filename(spec_name, format) + verbose_was, Migration.verbose = Migration.verbose, verbose? && ENV["VERBOSE"] check_schema_file(file) ActiveRecord::Base.establish_connection(configuration) @@ -261,6 +262,8 @@ module ActiveRecord end ActiveRecord::InternalMetadata.create_table ActiveRecord::InternalMetadata[:environment] = environment + ensure + Migration.verbose = verbose_was end def schema_file(format = ActiveRecord::Base.schema_format) diff --git a/activerecord/lib/active_record/test_databases.rb b/activerecord/lib/active_record/test_databases.rb index 606a3b0fb5..071e8924c4 100644 --- a/activerecord/lib/active_record/test_databases.rb +++ b/activerecord/lib/active_record/test_databases.rb @@ -5,14 +5,14 @@ require "active_support/testing/parallelization" module ActiveRecord module TestDatabases # :nodoc: ActiveSupport::Testing::Parallelization.after_fork_hook do |i| - create_and_migrate(i, spec_name: Rails.env) + create_and_load_schema(i, spec_name: Rails.env) end - ActiveSupport::Testing::Parallelization.run_cleanup_hook do |i| - drop(i, spec_name: Rails.env) + ActiveSupport::Testing::Parallelization.run_cleanup_hook do |_| + drop(spec_name: Rails.env) end - def self.create_and_migrate(i, spec_name:) + def self.create_and_load_schema(i, spec_name:) old, ENV["VERBOSE"] = ENV["VERBOSE"], "false" connection_spec = ActiveRecord::Base.configurations[spec_name] @@ -20,13 +20,13 @@ module ActiveRecord connection_spec["database"] += "-#{i}" ActiveRecord::Tasks::DatabaseTasks.create(connection_spec) ActiveRecord::Base.establish_connection(connection_spec) - ActiveRecord::Tasks::DatabaseTasks.migrate + ActiveRecord::Tasks::DatabaseTasks.load_schema(connection_spec) ensure ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations[Rails.env]) ENV["VERBOSE"] = old end - def self.drop(i, spec_name:) + def self.drop(spec_name:) old, ENV["VERBOSE"] = ENV["VERBOSE"], "false" connection_spec = ActiveRecord::Base.configurations[spec_name] |