Skip to content

Commit

Permalink
Fix update_replica_config for rails 6
Browse files Browse the repository at this point in the history
  • Loading branch information
David Kutalek authored and David Kutalek committed Jan 9, 2024
1 parent 68a59db commit 9b0836f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/knockoff/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ def replica_env_keys

def update_replica_configs(new_configs)
if ActiveRecord::Base.configurations.configs_for(env_name: 'knockoff_replicas').present?
new_configs.deep_dup.merge!(ActiveRecord::Base.configurations.configs_for(env_name: 'knockoff_replicas').first.configuration_hash)
updated_config = new_configs.deep_dup.merge!(ActiveRecord::Base.configurations.configs_for(env_name: 'knockoff_replicas').first.configuration_hash)
end

@replicas_configurations.each do |key, _config|
update_replica_config(key, new_configs)
update_replica_config(key, updated_config)
end
end

Expand All @@ -52,9 +52,9 @@ def properly_configured?

private

def update_replica_config(key, new_configs)
@replicas_configurations[key].merge!(new_configs)
ActiveRecord::Base.configurations[key].merge!(new_configs)
def update_replica_config(key, updated_config)
@replicas_configurations[key].merge!(updated_config)
ActiveRecord::Base.configurations.configurations << @replicas_configurations[key]
end

def set_replica_configs
Expand Down

0 comments on commit 9b0836f

Please sign in to comment.