Skip to content

Commit

Permalink
potential fix for rails 6.0 issue
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 ebef5de commit 876cd65
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/knockoff/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def replica_env_keys

def update_replica_configs(new_configs)
if ActiveRecord::Base.configurations.configs_for(env_name: 'knockoff_replicas').present?
updated_config = 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.to_h)
end

@replicas_configurations.each do |key, _config|
Expand All @@ -53,7 +53,7 @@ def properly_configured?
private

def update_replica_config(key, updated_config)
merged_config = @replicas_configurations[key].configuration_hash.deep_dup.merge!(updated_config)
merged_config = @replicas_configurations[key].to_h.deep_dup.merge!(updated_config)
@replicas_configurations[key] = ActiveRecord::DatabaseConfigurations::HashConfig.new(key, key, merged_config)
ActiveRecord::Base.configurations.configurations << @replicas_configurations[key]
end
Expand All @@ -69,7 +69,7 @@ def parse_knockoff_replica_envs_to_configs
begin

# Configure parameters such as prepared_statements, pool, reaping_frequency for all replicas.
to_copy = ActiveRecord::Base.configurations.configs_for(env_name: 'knockoff_replicas')&.first&.configuration_hash || {}
to_copy = ActiveRecord::Base.configurations.configs_for(env_name: 'knockoff_replicas')&.first&.to_h || {}
register_replica_copy(index, env_key, to_copy)

rescue URI::InvalidURIError
Expand Down

0 comments on commit 876cd65

Please sign in to comment.