Catch schema drift nightly
Every night at 3am, dump the production schema and diff it against migrations, filing issues for any drift found.
/schedule every night at 3am, dump the live database schema (`pg_dump --schema-only`) and diff it against the schema produced by applying all committed migrations to a fresh scratch database. Verify the scratch build reports `migrate status` clean before comparing. Any drift — columns, indexes, or constraints present in prod but missing from migrations, or vice versa — gets an issue filed with the exact diff attached and a proposed corrective migration for human review. Read-only against production; never modify the live schema. Stop after 1 pass per run.
claude-code
More database loops
Clean production data to spec
Remove disallowed records, sharpen the classification logic, and verify the remaining dataset against an explicit definition.
Review production records, remove anything that does not meet the allowed definition, improve the classification logic, and verify the remaining data.
databasehigh risk
Apply database migrations cleanly
Run migrations, fix schema or SQL errors, and repeat until prisma migrate status reports clean, capped at 6 turns.
/goal all database migrations apply cleanly — run them, fix schema or SQL errors, repeat until `npx prisma migrate status` is clean; stop after 6 turns
databasemedium risk
Index every foreign key
Query the catalog for unindexed foreign keys, create a migration per missing index, and verify each with a full test run until all FKs are covered or 6 turns complete.
/goal every foreign key in the schema has a covering index — query the catalog (pg_catalog or information_schema) to list FKs with no matching index, add one migration per missing index, and re-run the catalog check until it returns zero rows. After each index, apply the migration on a scratch database and run the full test suite to verify nothing regresses; stop after 6 turns. Only add indexes — never change constraints or table definitions — and propose the final migration set as a PR for review.
databasehigh risk