lib/parallel_tests/tasks.rb in parallel_tests-3.5.1 vs lib/parallel_tests/tasks.rb in parallel_tests-3.5.2

- old
+ new

@@ -121,15 +121,17 @@ desc "Update test databases by dumping and loading --> parallel:prepare[num_cpus]" task(:prepare, [:count]) do |_, args| ParallelTests::Tasks.check_for_pending_migrations if defined?(ActiveRecord::Base) && [:ruby, :sql].include?(ActiveRecord::Base.schema_format) # fast: dump once, load in parallel - if Gem::Version.new(Rails.version) >= Gem::Version.new('6.1.0') - Rake::Task["db:schema:dump"].invoke - else - type = (ActiveRecord::Base.schema_format == :ruby ? "schema" : "structure") - Rake::Task["db:#{type}:dump"].invoke - end + type = + if Gem::Version.new(Rails.version) >= Gem::Version.new('6.1.0') + "schema" + else + ActiveRecord::Base.schema_format == :ruby ? "schema" : "structure" + end + + Rake::Task["db:#{type}:dump"].invoke # remove database connection to prevent "database is being accessed by other users" ActiveRecord::Base.remove_connection if ActiveRecord::Base.configurations.any? Rake::Task["parallel:load_#{type}"].invoke(args[:count])