Labels: backend infrastructure database
Background
scripts/validate-migrations.ts (2.7 KB) checks that migration files are ordered correctly but does not compare the actual DB schema against what the migrations should have produced. Schema drift (direct DB edits in staging accidentally applied to prod) is undetectable.
What "Done" Looks Like
- Script connects to the target DB and runs
pg_dump --schema-only
- Compares the dump against the expected schema derived by running all migrations on a fresh DB
- Reports any columns/tables/indexes present in the DB but absent from the migration history (and vice versa)
- Runnable as
npm run validate:schema -- --env production
- Non-destructive: read-only DB connection
Labels:
backendinfrastructuredatabaseBackground
scripts/validate-migrations.ts(2.7 KB) checks that migration files are ordered correctly but does not compare the actual DB schema against what the migrations should have produced. Schema drift (direct DB edits in staging accidentally applied to prod) is undetectable.What "Done" Looks Like
pg_dump --schema-onlynpm run validate:schema -- --env production