Repository navigation
feat(db): run Precedent and patch notes on each site's own Postgres - #250
Merged
Merged
Conversation
Precedent and patch notes lived in a Supabase project shared by nothing else, and Dev had no database at all. Each site's compose project now has a db service (pgvector, Postgres 17 to match Supabase), reached as db with no host port, and the backend waits for it to be healthy. - SUPABASE_DB_URL is renamed DATABASE_URL everywhere (the Database studio source id becomes postgres). - site-deploy starts db when the checked-out compose file defines it and writes a pg_dump next to the province.db backup, keeping 10. - Staging's unused patchnotes-db becomes db with the same settings as www. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 22 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…ample Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Author
|
Reviewed by Muse (muse-wonder-full) over two rounds; round 2 returned VERDICT: OK. The host switchover follows. |
This branch was successfully deployed
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
Precedent and patch notes lived in a Supabase project used by nothing else, and Dev had no Precedent at all (its override drops the setting). This is step 1 of moving the site off Supabase and, later,
province.dbinto the same Postgres.What changes
dbservice indocker-compose.ymlanddocker-compose.staging.yml:pgvector/pgvector:pg17(Supabase runs 17.6), volumedb, healthcheck, no host port. The backenddepends_onit as healthy. www's password comes from the project's.env(${POSTGRES_PASSWORD:?}); staging has a dev default. Staging's unusedpatchnotes-db(pg16) is replaced.SUPABASE_DB_URL→DATABASE_URLinpatchnotes/db.py,precedent/db.py, the Database studio (source idsupabase→postgres) andbackfill_precedent_embeddings.py, with the tests renamed to match.site-deploystartsdb(up -d --wait) when the checked-out compose file defines it, both before the backup and before the rebuild, and writespostgres.before-deploy-<sha>-<time>.dump(pg_dump -Fc), keeping 10. It checks the compose file first, so the first deploy of this commit (whose backup runs on the old checkout) doesn't fail.Data (12 tables, 15 MB in Supabase)
publicholds only the 10patchnote_*tables and 2precedent_*tables: 225 cases withvector(1024)embeddings, 32 audit rows and about 2,400 patch-note rows. There are no RLS policies, triggers or functions.Host steps
Done before merge: both project
.envfiles have a hexPOSTGRES_PASSWORD(so eachdbvolume is created with the real one, not the staging default), and www'sbackend/.envhasDATABASE_URLwith the Supabase URL.After merge: install
scripts/site-deploy.shfrom the merge commit. The Dev deploy that the merge triggers runs the old installed script, which doesn't startdb. That's harmless, because Dev has noDATABASE_URLuntil it's switched over. Then switch each site over by hand:ps-compose <site> up -d --wait db, stop the patch-note jobs,pg_dump -n publicfrom Supabase, restore intodb, compare row counts, pointDATABASE_URLatdb(adding it to Dev's override), recreate the backend and restart the jobs. Dev gets a copy of www's data. Supabase is left untouched as the fallback until both sites are checked.Tests:
src/patchnotes/test_db.py,src/precedent,src/dbstudioandtest_precedent_routes.py: 128 passed, 3 skipped. Both compose files passdocker compose config.Docs: TF-Minecraft/Docs#285
🤖 Generated with Claude Code