mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-30 19:08:10 -05:00
BUGFIX: make sure we can access db config hash with either strings or symbols
This commit is contained in:
parent
1f90f3044f
commit
918af0c6ee
1 changed files with 9 additions and 9 deletions
|
@ -104,15 +104,15 @@ module BackupRestore
|
||||||
DatabaseConfiguration = Struct.new(:host, :username, :password, :database)
|
DatabaseConfiguration = Struct.new(:host, :username, :password, :database)
|
||||||
|
|
||||||
def self.database_configuration
|
def self.database_configuration
|
||||||
if Rails.env.production?
|
config = Rails.env.production? ? ActiveRecord::Base.connection_pool.spec.config : Rails.configuration.database_configuration[Rails.env]
|
||||||
db = ActiveRecord::Base.connection_pool.spec.config
|
config = config.with_indifferent_access
|
||||||
db_conf = DatabaseConfiguration.new(db["host"], db["username"], db["password"], db["database"])
|
|
||||||
else
|
DatabaseConfiguration.new(
|
||||||
db = Rails.configuration.database_configuration[Rails.env]
|
config["host"],
|
||||||
db_conf = DatabaseConfiguration.new(db["host"], db["username"], db["password"], db["database"])
|
config["username"] || ENV["USER"] || "postgres",
|
||||||
end
|
config["password"],
|
||||||
db_conf.username ||= ENV["USER"] || "postgres"
|
config["database"]
|
||||||
db_conf
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
Loading…
Reference in a new issue