Sha256: ae33f9d3f6f86676a43df5e14aa5954c0c00e347967ce85f18ccbe8822d1289b

Contents?: true

Size: 782 Bytes

Versions: 77

Compression:

Stored size: 782 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: ActiveRecord::ConnectionHandling::DEFAULT_ENV.call)
    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._database = "#{db_config.database}-#{i}"

        ActiveRecord::Tasks::DatabaseTasks.reconstruct_from_schema(db_config, ActiveRecord.schema_format, nil)
      end
    ensure
      ActiveRecord::Base.establish_connection
      ENV["VERBOSE"] = old
    end
  end
end

Version data entries

77 entries across 74 versions & 7 rubygems

Version Path
activerecord-8.0.0 lib/active_record/test_databases.rb
activerecord-7.2.2 lib/active_record/test_databases.rb
activerecord-7.1.5 lib/active_record/test_databases.rb
activerecord-8.0.0.rc2 lib/active_record/test_databases.rb
activerecord-7.2.1.2 lib/active_record/test_databases.rb
activerecord-7.1.4.2 lib/active_record/test_databases.rb
activerecord-7.0.8.6 lib/active_record/test_databases.rb
activerecord-8.0.0.rc1 lib/active_record/test_databases.rb
activerecord-7.2.1.1 lib/active_record/test_databases.rb
activerecord-7.1.4.1 lib/active_record/test_databases.rb
activerecord-7.0.8.5 lib/active_record/test_databases.rb
activerecord-8.0.0.beta1 lib/active_record/test_databases.rb
omg-activerecord-8.0.0.alpha9 lib/active_record/test_databases.rb
omg-activerecord-8.0.0.alpha8 lib/active_record/test_databases.rb
omg-activerecord-8.0.0.alpha7 lib/active_record/test_databases.rb
omg-activerecord-8.0.0.alpha4 lib/active_record/test_databases.rb
omg-activerecord-8.0.0.alpha3 lib/active_record/test_databases.rb
omg-activerecord-8.0.0.alpha2 lib/active_record/test_databases.rb
omg-activerecord-8.0.0.alpha1 lib/active_record/test_databases.rb
activerecord-7.1.4 lib/active_record/test_databases.rb