From 8878a8177455fcd18feca1a649efc57080da2eee Mon Sep 17 00:00:00 2001 From: Saverio Trioni Date: Thu, 24 Mar 2016 09:20:43 +0100 Subject: [PATCH 1/5] Rails complains when the `database.url` key is not an url --- config/database.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config/database.yml b/config/database.yml index e3610dd..c5bcc64 100644 --- a/config/database.yml +++ b/config/database.yml @@ -14,4 +14,5 @@ test: database: <%= ENV.fetch('DATABASE_NAME', 'timeoverflow_test') %> production: - url: <%= ENV.fetch('DATABASE_URL', 'Set DATABASE_URL environment variable') %> + # Set DATABASE_URL environment variable + url: <%= ENV.fetch('DATABASE_URL', 'null') %> From 1722d635b0316dfd106d019416c52f971141ba02 Mon Sep 17 00:00:00 2001 From: Saverio Trioni Date: Thu, 24 Mar 2016 10:11:50 +0100 Subject: [PATCH 2/5] Much simpler database config --- config/database.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/config/database.yml b/config/database.yml index c5bcc64..f0fae3a 100644 --- a/config/database.yml +++ b/config/database.yml @@ -1,8 +1,8 @@ defaults: &defaults adapter: postgresql - host: <%= ENV.fetch('DATABASE_HOST', 'localhost') %> - username: <%= ENV.fetch('DATABASE_USER', 'null') %> - password: <%= ENV.fetch('DATABASE_PASSWORD', 'null') %> + host: <%= ENV['DATABASE_HOST'] %> # default is localhost + username: <%= ENV['DATABASE_USER'] %> # default is null + password: <%= ENV['DATABASE_PASSWORD'] %> # default is null encoding: utf8 development: @@ -15,4 +15,4 @@ test: production: # Set DATABASE_URL environment variable - url: <%= ENV.fetch('DATABASE_URL', 'null') %> + url: <%= ENV['DATABASE_URL'] %> From b4233a227e5af5754c404fac8995f6caa984abb9 Mon Sep 17 00:00:00 2001 From: Saverio Trioni Date: Thu, 24 Mar 2016 10:41:09 +0100 Subject: [PATCH 3/5] Add comment on how to keep local changes on tracked files --- config/database.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/config/database.yml b/config/database.yml index f0fae3a..11ea585 100644 --- a/config/database.yml +++ b/config/database.yml @@ -1,3 +1,9 @@ +# If you want to change this file, please keep the changes in your working +# copy by using +# +# git update-index --assume-unchanged config/database.yml +# + defaults: &defaults adapter: postgresql host: <%= ENV['DATABASE_HOST'] %> # default is localhost From c91fb665049197248be6e3aee036c3e9bc5d640e Mon Sep 17 00:00:00 2001 From: Saverio Trioni Date: Thu, 24 Mar 2016 10:50:41 +0100 Subject: [PATCH 4/5] Use --skip-worktree to have local versions of files --- config/database.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/database.yml b/config/database.yml index 11ea585..937e01d 100644 --- a/config/database.yml +++ b/config/database.yml @@ -1,7 +1,7 @@ # If you want to change this file, please keep the changes in your working # copy by using # -# git update-index --assume-unchanged config/database.yml +# git update-index --skip-worktree config/database.yml # defaults: &defaults From ec4cce279d9adab16bdc7d4d54d8a4b0515f1f8d Mon Sep 17 00:00:00 2001 From: Saverio Trioni Date: Thu, 24 Mar 2016 11:47:12 +0100 Subject: [PATCH 5/5] Link to the wiki --- config/database.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/config/database.yml b/config/database.yml index 937e01d..5d48942 100644 --- a/config/database.yml +++ b/config/database.yml @@ -3,6 +3,12 @@ # # git update-index --skip-worktree config/database.yml # +# or just use DATABASE_URL, in which case Rails will happily skip the whole +# file. +# +# See https://github.com/coopdevs/timeoverflow/wiki/Keeping-your-local-files +# for more information +# defaults: &defaults adapter: postgresql