Module: ActiveRecordShards::Tasks

Defined in:
lib/active_record_shards/tasks.rb

Class Method Summary collapse

Class Method Details

.root_connection(conf) ⇒ Object



121
122
123
124
125
126
127
128
129
130
# File 'lib/active_record_shards/tasks.rb', line 121

def root_connection(conf)
  conf = conf.merge('database' => nil)
  spec = spec_for(conf)
  case "#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}"
  when '6.1', '7.0'
    ActiveRecord::Base.send("#{conf['adapter']}_connection", spec.db_config.configuration_hash)
  else
    ActiveRecord::Base.send("#{conf['adapter']}_connection", spec.config)
  end
end