lib/standby/connection_holder.rb in standby-4.0.0 vs lib/standby/connection_holder.rb in standby-5.0.0

- old
+ new

@@ -3,12 +3,18 @@ self.abstract_class = true class << self # for delayed activation def activate(target) - spec = ActiveRecord::Base.configurations["#{ActiveRecord::ConnectionHandling::RAILS_ENV.call}_#{target}"] - raise Error.new("Standby target '#{target}' is invalid!") if spec.nil? + env_name = "#{ActiveRecord::ConnectionHandling::RAILS_ENV.call}_#{target}" + if Standby.version_gte?('7.0') + spec = ActiveRecord::Base.configurations.find_db_config(env_name)&.configuration_hash + else + spec = ActiveRecord::Base.configurations[env_name] + end + raise Error, "Standby target '#{target}' is invalid!" if spec.nil? + establish_connection spec end end end @@ -23,6 +29,6 @@ klass.activate(target) klass end end end -end +end \ No newline at end of file