mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 17:46:05 -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)
|
||||
|
||||
def self.database_configuration
|
||||
if Rails.env.production?
|
||||
db = ActiveRecord::Base.connection_pool.spec.config
|
||||
db_conf = DatabaseConfiguration.new(db["host"], db["username"], db["password"], db["database"])
|
||||
else
|
||||
db = Rails.configuration.database_configuration[Rails.env]
|
||||
db_conf = DatabaseConfiguration.new(db["host"], db["username"], db["password"], db["database"])
|
||||
end
|
||||
db_conf.username ||= ENV["USER"] || "postgres"
|
||||
db_conf
|
||||
config = Rails.env.production? ? ActiveRecord::Base.connection_pool.spec.config : Rails.configuration.database_configuration[Rails.env]
|
||||
config = config.with_indifferent_access
|
||||
|
||||
DatabaseConfiguration.new(
|
||||
config["host"],
|
||||
config["username"] || ENV["USER"] || "postgres",
|
||||
config["password"],
|
||||
config["database"]
|
||||
)
|
||||
end
|
||||
|
||||
private
|
||||
|
|
Loading…
Reference in a new issue