Repository navigation
Conversation
The dotenv generator now adds DB_HOST, DB_PORT, POSTGRES_USER and POSTGRES_PASSWORD to the default block in config/database.yml, read with EnvValue. Unset keys keep PostgreSQL's own defaults, and DATABASE_URL still wins on Heroku. It also adds a startup warning in development and test when a leftover .env_overrides.rb exists, since Git ignores that file and nothing loads it any more.
A user and password need a TCP connection. Without a host, PostgreSQL uses the local socket and its peer or trust login instead.
The dotenv generator now also adds these to the default block of config/database.yml: - max_connections (or pool) from DB_POOL, else RAILS_MAX_THREADS plus 2 - connect_timeout from DB_CONNECT_TIMEOUT, default 15 seconds - statement_timeout from DB_STATEMENT_TIMEOUT, default 15s - lock_timeout from DB_LOCK_TIMEOUT, default 10s The README explains each key and how to raise the statement timeout for a slow migration or import.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why?
.env.local. A developer whose PostgreSQL runs in Docker or on another computer had to editconfig/database.ymlto connect. Now they setDB_HOST,DB_PORT,POSTGRES_USERandPOSTGRES_PASSWORDin.env.local..env_overrides.rb. Since Switch from env.rb to .env #224, apps keep local settings in.env.localand no longer load.env_overrides.rb. Git ignores the old file, so each developer's copy stays behind and its settings are silently ignored; the app now warns at startup until the developer deletes it.RAILS_MAX_THREADSplus 2, up fromRAILS_MAX_THREADS, so background threads such as GoodJob's don't take connections the web threads need. To change them, setDB_POOL,DB_CONNECT_TIMEOUT,DB_STATEMENT_TIMEOUTandDB_LOCK_TIMEOUT.If
DB_HOST,DB_PORT,POSTGRES_USERandPOSTGRES_PASSWORDare unset, the app connects to the same server as before. On Heroku,DATABASE_URLstill overrides those four keys. The statement and lock timeouts are new behavior: a statement that runs longer than 15 seconds, or waits more than 10 seconds for a lock, now fails. To raise the statement timeout for a slow migration or import, setDB_STATEMENT_TIMEOUTto a PostgreSQL duration such as30min, or to0to turn it off. The dotenv README has examples.What Changed
defaultblock ofconfig/database.yml.env_overrides.rbstill existsPre-merge checklist
Notes
Please don't commit version changes within your PR. Versioning, releasing, and changelog entries are managed through the Release workflow.