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

- old
+ new

@@ -121,12 +121,16 @@ 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 - type = (ActiveRecord::Base.schema_format == :ruby ? "schema" : "structure") - Rake::Task["db:#{type}:dump"].invoke + 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 # 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]) @@ -161,10 +165,11 @@ "db:schema:load RAILS_ENV=#{ParallelTests::Tasks.rails_env} DISABLE_DATABASE_ENVIRONMENT_CHECK=1" ParallelTests::Tasks.run_in_parallel(ParallelTests::Tasks.suppress_schema_load_output(command), args) end # load the structure from the structure.sql file - desc "Load structure for test databases via db:structure:load --> parallel:load_structure[num_cpus]" + # (faster for rails < 6.1, deprecated after and only configured by `ActiveRecord::Base.schema_format`) + desc "Load structure for test databases via db:schema:load --> parallel:load_structure[num_cpus]" task :load_structure, :count do |_, args| ParallelTests::Tasks.run_in_parallel( "#{ParallelTests::Tasks.rake_bin} #{ParallelTests::Tasks.purge_before_load} " \ "db:structure:load RAILS_ENV=#{ParallelTests::Tasks.rails_env} DISABLE_DATABASE_ENVIRONMENT_CHECK=1", args )