default: &default

adapter: postgresql
encoding: unicode
# For details on connection pooling, see Rails configuration guide
# https://guides.rubyonrails.org/configuring.html#database-pooling
pool: <%%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
connect_timeout: <%%= ENV.fetch("DB_CONNECT_TIMEOUT") { 2 } %>
checkout_timeout: <%%= ENV.fetch("DB_CHECKOUT_TIMEOUT") { 5 } %>
variables:
  # Prevent single queries from taking up all of your database’s resources
  # https://github.com/ankane/the-ultimate-guide-to-ruby-timeouts#postgresql
  statement_timeout: <%%= ENV.fetch("DB_STATEMENT_TIMEOUT") { "5s" } %>

development:

<<: *default
database: <%= app_name %>_development

test:

<<: *default
url: <%%= ENV.fetch('TEST_DATABASE_URL', "postgres://localhost/<%= app_name %>_test") %>

production:

<<: *default
url: <%%= ENV['DATABASE_URL'] %>