Sha256: a461386a86a2b7e9d3f9e37a181c542b257073d8801fec940fbb965e69d4748d

Contents?: true

Size: 791 Bytes

Versions: 34

Compression:

Stored size: 791 Bytes

Contents

# frozen_string_literal: true

require "active_support/testing/parallelization"

module ActiveRecord
  module TestDatabases # :nodoc:
    ActiveSupport::Testing::Parallelization.after_fork_hook do |i|
      create_and_load_schema(i, env_name: Rails.env)
    end

    def self.create_and_load_schema(i, env_name:)
      old, ENV["VERBOSE"] = ENV["VERBOSE"], "false"

      ActiveRecord::Base.configurations.configs_for(env_name: env_name).each do |db_config|
        db_config.config["database"] += "-#{i}"
        ActiveRecord::Tasks::DatabaseTasks.reconstruct_from_schema(db_config.config, ActiveRecord::Base.schema_format, nil, env_name, db_config.spec_name)
      end
    ensure
      ActiveRecord::Base.establish_connection(Rails.env.to_sym)
      ENV["VERBOSE"] = old
    end
  end
end

Version data entries

34 entries across 34 versions & 4 rubygems

Version Path
activerecord-6.0.6.1 lib/active_record/test_databases.rb
activerecord-6.0.6 lib/active_record/test_databases.rb
activerecord-6.0.5.1 lib/active_record/test_databases.rb
activerecord-6.0.5 lib/active_record/test_databases.rb
activerecord-6.0.4.8 lib/active_record/test_databases.rb
activerecord-6.0.4.7 lib/active_record/test_databases.rb
activerecord-6.0.4.6 lib/active_record/test_databases.rb
activerecord-6.0.4.5 lib/active_record/test_databases.rb
activerecord-6.0.4.4 lib/active_record/test_databases.rb
activerecord-6.0.4.3 lib/active_record/test_databases.rb
activerecord-6.0.4.2 lib/active_record/test_databases.rb
activerecord-6.0.4.1 lib/active_record/test_databases.rb
activerecord-6.0.4 lib/active_record/test_databases.rb
activerecord-6.0.3.7 lib/active_record/test_databases.rb
activerecord-6.0.3.6 lib/active_record/test_databases.rb
activerecord-6.0.3.5 lib/active_record/test_databases.rb
activerecord-6.0.3.4 lib/active_record/test_databases.rb
activerecord-6.0.3.3 lib/active_record/test_databases.rb
activerecord-6.0.3.2 lib/active_record/test_databases.rb
activerecord-6.0.3.1 lib/active_record/test_databases.rb