Harden migration preflight and startup adoption checks
All checks were successful
Verify and publish container / build-and-push (push) Successful in 1m26s

This commit is contained in:
Elijah 2026-08-08 18:17:17 -07:00
parent 931e674814
commit 5db7fc8afd
4 changed files with 228 additions and 54 deletions

View file

@ -61,12 +61,18 @@ The material-group preflight reports one of four states:
- `APPLY`: migration history is complete and the group schema is absent; run
`prisma migrate deploy` normally.
- `ADOPT`: prior migrations are tracked and the database exactly matches the
intended group schema. After reviewing the verified backup, explicitly run
intended schema of one or more unrecorded committed migrations. This includes
recovery from P3018 when an already schema-pushed table or column exists.
After reviewing the verified backup, explicitly run
`npm run db:preflight -- --resolve --backup <backup-path>`.
- `CURRENT`: migration and schema already agree.
- `CONFLICT`: partial or unknown state. Stop and recover manually; do not use
`db push`, reset, edit applied migrations, or mark anything applied.
The production entrypoint runs this preflight before `prisma migrate deploy`.
It refuses `ADOPT` and `CONFLICT` states without changing migration history;
adoption always remains an explicit backup-gated operator action.
Restore drill: stop Study Desk, keep the damaged database as evidence, restore
the verified backup to a new path, run SQLite `integrity_check` plus
`npm run db:preflight`, start the same prior application image against the