mirror of
https://github.com/jjbrunton/Sauci.git
synced 2026-10-31 18:19:43 +00:00
1.7 KiB
1.7 KiB
Database migration safety
The standalone PostgreSQL schema is owned by ordered SQL files under
apps/api/drizzle/. Hosted Supabase owns Auth only; its legacy product-data
migrations and Edge Functions are retained as cutover history and are not a
deployment target.
Required workflow
- Add the next ordered SQL migration under
apps/api/drizzle/. - Keep application, repository, shared-contract, and client changes in the same reviewed change where the schema contract requires them.
- Run
npm run verify:fullagainst the dedicated loopback PostgreSQL service. - Run
infra/backend/verify-production.shfor container and migration startup. - Merge to
staging; the Dokploy migration service applies the committed files under an advisory lock before the API receives traffic. - Prove staging health and affected authenticated behavior before promoting the
exact commit from
stagingtomain.
Safety invariants
- Never point local integration tests, reset commands, or disposable verification at a remote database.
- Never deploy
apps/supabase/migrationsorapps/supabase/functionsas part of the standalone backend release. - Never execute DDL through MCP or provider SQL tools.
- Never edit migration history already applied to a persistent environment; add a forward migration.
- Back up PostgreSQL and private media together before a destructive production migration or data import, and prove restore separately.
- A failed migration must block API startup. Do not bypass the one-shot
migrateservice to force new code against an old schema.
Production data cutover has additional stop-source, final-sync, parity, legacy media, and authenticated-mobile checks in backend-cutover.md.