From 7ee41902f25a2d2a7bcc1914e023189c475b0957 Mon Sep 17 00:00:00 2001 From: Pau Perez Date: Tue, 18 Jun 2019 11:01:58 +0200 Subject: [PATCH] DRY and make database.yml more flexible This enables us to fix https://github.com/openfoodfoundation/ofn-install/issues/387 and brings the needed flexibility so things like https://github.com/openfoodfoundation/openfoodnetwork/pull/3887 or any CI don't require a custom version. That's what ENV vars are for! For instance, I no longer need to mess with my LXC setup to connect to the DB. I just need to have 2 env vars. --- config/database.yml | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/config/database.yml b/config/database.yml index 9ef24edfd3..84d4ad2861 100644 --- a/config/database.yml +++ b/config/database.yml @@ -1,19 +1,23 @@ -default: &default +defaults: &defaults adapter: postgresql - encoding: utf8 + encoding: unicode pool: 5 - timeout: 5000 - host: db - port: 5432 + host: localhost + username: <%= ENV.fetch('DB_USERNAME', 'ofn') %> + password: <%= ENV.fetch('DB_PASSWORD', 'f00d') %> development: - <<: *default + <<: *defaults database: open_food_network_dev - username: ofn - password: f00d test: - <<: *default + <<: *defaults database: open_food_network_test - username: ofn - password: f00d + +production: + <<: *defaults + database: open_food_network_prod + +staging: + <<: *defaults + database: open_food_network_prod