Simplify database.yml by merging in default options
Anything in the &default section can be merged in using <<: *default In this case, the default already specifies that the adapter is postgresql, the timeout is 5000, the encoding is unicode. It also already specified the db pool, but the default actually checked 2 different ENVs and provided a fallback if it's not provided. Lastly, I was able to move the prepared_statements section to the defaults, because the .env.vagrant file doesn't specify ENV['PREPARED_STATEMENTS'], development still just sets it to 'false'.
This commit is contained in:
parent
70c44fc68d
commit
903b6c7969
@ -4,26 +4,18 @@ default: &default
|
||||
timeout: 5000
|
||||
encoding: unicode
|
||||
sslmode: <%= ENV['DB_SSLMODE'] || "prefer" %>
|
||||
prepared_statements: <%= ENV['PREPARED_STATEMENTS'] || 'false' %>
|
||||
|
||||
development:
|
||||
master:
|
||||
adapter: postgresql
|
||||
<<: *default
|
||||
url: <%= ENV['DB_MASTER_URL'] %>
|
||||
pool: <%= ENV['DB_POOL'] %>
|
||||
timeout: 5000
|
||||
encoding: unicode
|
||||
slave1:
|
||||
adapter: postgresql
|
||||
<<: *default
|
||||
url: <%= ENV['DB_SLAVE1_URL'] %>
|
||||
pool: <%= ENV['DB_POOL'] %>
|
||||
timeout: 5000
|
||||
encoding: unicode
|
||||
slave2:
|
||||
adapter: postgresql
|
||||
<<: *default
|
||||
url: <%= ENV['DB_SLAVE2_URL'] %>
|
||||
pool: <%= ENV['DB_POOL'] %>
|
||||
timeout: 5000
|
||||
encoding: unicode
|
||||
|
||||
# Warning: The database defined as "test" will be erased and
|
||||
# re-generated from your development database when you run "rake".
|
||||
@ -46,27 +38,11 @@ test:
|
||||
# prepared_statements: <%= ENV['PREPARED_STATEMENTS'] || 'true' %>
|
||||
production:
|
||||
master:
|
||||
adapter: postgresql
|
||||
sslmode: <%= ENV['DB_SSLMODE'] || "prefer" %>
|
||||
prepared_statements: <%= ENV['PREPARED_STATEMENTS'] || 'false' %>
|
||||
<<: *default
|
||||
url: <%= ENV['DB_MASTER_URL'] %>
|
||||
pool: <%= ENV['DB_POOL'] %>
|
||||
timeout: 5000
|
||||
encoding: unicode
|
||||
slave1:
|
||||
adapter: postgresql
|
||||
sslmode: <%= ENV['DB_SSLMODE'] || "prefer" %>
|
||||
prepared_statements: <%= ENV['PREPARED_STATEMENTS'] || 'false' %>
|
||||
<<: *default
|
||||
url: <%= ENV['DB_SLAVE1_URL'] %>
|
||||
pool: <%= ENV['DB_POOL'] %>
|
||||
timeout: 5000
|
||||
encoding: unicode
|
||||
slave2:
|
||||
adapter: postgresql
|
||||
sslmode: <%= ENV['DB_SSLMODE'] || "prefer" %>
|
||||
prepared_statements: <%= ENV['PREPARED_STATEMENTS'] || 'false' %>
|
||||
<<: *default
|
||||
url: <%= ENV['DB_SLAVE1_URL'] %>
|
||||
pool: <%= ENV['DB_POOL'] %>
|
||||
timeout: 5000
|
||||
encoding: unicode
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user