diff --git a/config/database.yml b/config/database.yml index 391aca940..2d3b24ed0 100644 --- a/config/database.yml +++ b/config/database.yml @@ -3,7 +3,6 @@ config = ClowderCommonRuby::Config.load - db_service = 'postgres' username = config.database.username password = config.database.password host = config.database.hostname @@ -13,7 +12,7 @@ db_service = ENV.fetch("DATABASE_SERVICE_NAME","").upcase.sub("-", "_") username = ENV.key?("POSTGRESQL_ADMIN_PASSWORD") ? "postgres" : ENV["POSTGRESQL_USER"] password = ENV.key?("POSTGRESQL_ADMIN_PASSWORD") ? ENV["POSTGRESQL_ADMIN_PASSWORD"] : ENV["POSTGRESQL_PASSWORD"] - host = ENV.fetch("POSTGRES_SERVICE_HOST") + host = ENV.fetch("#{db_service}_SERVICE_HOST") database = Rails.env.test? ? ENV['POSTGRESQL_TEST_DATABASE'] || ENV["POSTGRESQL_DATABASE"] : ENV["POSTGRESQL_DATABASE"] port = ENV.key?("POSTGRESQL_PORT") ? ENV["POSTGRESQL_PORT"] : 5432 end @@ -31,6 +30,7 @@ default: &default test: <<: *default + database: <%= ENV['POSTGRESQL_TEST_DATABASE'] || database %> production: <<: *default