feat: allow local Postgres for development/test#1355
Open
sh1nj1 wants to merge 1 commit into
Open
Conversation
Development and test still default to SQLite (zero-config, unchanged for existing worktrees). Opt into Postgres with DB_ADAPTER=postgresql (uses the local collavre_db / collavre_user with sensible env-overridable defaults) or by setting DATABASE_URL. Previously the development/test blocks hardcoded a SQLite database path, so a Postgres DATABASE_URL was silently ignored. Move the pg gem into the development and test groups so the adapter is available locally. Production and desktop configs are unchanged. Part of the SQLite -> Postgres migration; complements the db:sqlite_to_postgres data-copy task (#1350).
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
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.
Summary
Lets the Rails app run against a local PostgreSQL database in
development/test, as a step in the SQLite → Postgres migration. Previously thedevelopment/testblocks inconfig/database.ymlhardcoded a SQLite file path, so even setting a PostgresDATABASE_URLwas silently ignored (Rails would look for a Postgres DB literally namedstorage/development.sqlite3).Defaults are unchanged: with no env vars, dev/test still use SQLite — zero disruption to existing worktrees.
How to use
Adapter selection precedence in
database.yml:DATABASE_URLset → use its scheme (postgres/postgresqlnormalized).DB_ADAPTER=postgresql→ local Postgres, no URL required.sqlite3(default).Local Postgres defaults are env-overridable:
DATABASE_HOST(localhost),DATABASE_USERNAME(collavre_user),DATABASE_PASSWORD,DATABASE_NAME(collavre_db),TEST_DATABASE_NAME(collavre_test).Changes
config/database.yml— dev/test blocks branch on adapter; Postgres usesurl:(URL mode) or localcollavre_db/collavre_userdefaults.productionanddesktopblocks untouched.Gemfile— movepginto the:developmentand:testgroups (was:productiononly) so the adapter loads locally. Requires libpq.Gemfile.lockunchanged (groups aren't recorded there).env.template— documents the new opt-in dev/test Postgres vars.Verification (live, local)
DB_ADAPTER=postgresql bin/rails runner→adapter=PostgreSQL,database=collavre_db,user=collavre_user,server=14.15 (Homebrew), 35 tables. ✅default_adapter=sqlite3(unchanged). ✅DATABASE_URL=postgres://…→PostgreSQL. ✅Notes
db:sqlite_to_postgresdata-copy task); this PR is the config side, that PR moves the data.