Sha256: d61995dc2dd34516471c09a69d86b288bc14fdb4a0b070a828068502eff5e1c0

Contents?: true

Size: 788 Bytes

Versions: 37

Compression:

Stored size: 788 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::Base.schema_format, nil)
      end
    ensure
      ActiveRecord::Base.establish_connection
      ENV["VERBOSE"] = old
    end
  end
end

Version data entries

37 entries across 37 versions & 4 rubygems

Version Path
activerecord-6.1.7.10 lib/active_record/test_databases.rb
activerecord-6.1.7.9 lib/active_record/test_databases.rb
activerecord-6.1.7.8 lib/active_record/test_databases.rb
activerecord-6.1.7.7 lib/active_record/test_databases.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/activerecord-6.1.6.1/lib/active_record/test_databases.rb
activerecord-6.1.7.6 lib/active_record/test_databases.rb
activerecord-6.1.7.5 lib/active_record/test_databases.rb
activerecord-6.1.7.4 lib/active_record/test_databases.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/activerecord-6.1.6.1/lib/active_record/test_databases.rb
activerecord-6.1.7.3 lib/active_record/test_databases.rb
activerecord-6.1.7.2 lib/active_record/test_databases.rb
activerecord-6.1.7.1 lib/active_record/test_databases.rb
activerecord-6.1.7 lib/active_record/test_databases.rb
activerecord-6.1.6.1 lib/active_record/test_databases.rb
activerecord-6.1.6 lib/active_record/test_databases.rb
activerecord-6.1.5.1 lib/active_record/test_databases.rb
activerecord-6.1.5 lib/active_record/test_databases.rb
activerecord-6.1.4.7 lib/active_record/test_databases.rb
activerecord-6.1.4.6 lib/active_record/test_databases.rb
activerecord-6.1.4.5 lib/active_record/test_databases.rb