Skip to content

Commit

Permalink
Another attempt for a new error
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 8029456 commit d307115
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions lib/knockoff/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def properly_configured?
private

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

Expand Down Expand Up @@ -90,14 +90,12 @@ def register_replica_copy(index, env_key, configuration_hash)
key = "knockoff_replica_#{index}"
new_config = create_replica_copy(env_key, key, configuration_hash.deep_dup)
ActiveRecord::Base.configurations.configurations << new_config
@replicas_configurations[key] = new_config.configuration_hash.deep_dup
@replicas_configurations[key] = new_config
end

def create_replica_copy(env_key, key, replica_config_hash)
uri = URI.parse(ENV[env_key])

puts uri

replica_config_hash[:adapter] =
if uri.scheme == "postgres"
'postgresql'
Expand All @@ -114,9 +112,6 @@ def create_replica_copy(env_key, key, replica_config_hash)
replica_config_hash[:host] = uri.host
replica_config_hash[:port] = uri.port
end

puts (uri.path || "").split("/")[1]
puts replica_config_hash

ActiveRecord::DatabaseConfigurations::HashConfig.new(key, key, replica_config_hash)
end
Expand Down

0 comments on commit d307115

Please sign in to comment.