Skip to content

Commit

Permalink
Merge pull request #31 from joinhandshake/davkutalek/6-0-bugfix
Browse files Browse the repository at this point in the history
Fix for rails 6.0
  • Loading branch information
amy-hs authored Jan 10, 2024
2 parents ebef5de + 3cd53c5 commit 9ad0838
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.config)
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].config.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&.config || {}
register_replica_copy(index, env_key, to_copy)

rescue URI::InvalidURIError
Expand Down

0 comments on commit 9ad0838

Please sign in to comment.