← ClaudeAtlas

schema-difflisted

Diff the ORM entities against the actual DB schema — catch drift between code and reality. Run before generating a new migration (drift corrupts autogenerate output), after an out-of-band hotfix, and weekly in CI against a restored backup. Detects drift only — `migration-rehearsal` is what proves the corrective migration is safe to apply.
adnanmokhtar/refract · ★ 1 · Code & Development · score 77
Install: claude install-skill adnanmokhtar/refract
# schema-diff When migrations are skipped, hand-edited on prod, or entities change without a generated migration, the ORM and DB drift. This skill catches it. ## Premise Find real drift, cite `<table>.<column>` and the file/line in the entity definition. Every finding maps to a concrete artifact: a column visible in `pg_dump` output, an entity field in `prisma/schema.prisma:NN`, an index declared in `*.entity.ts:NN`. No "looks like drift" — either the diff tool emits it or it's not reported. Verdicts (blocker / warning / info) come from the captured diff, not from intuition about the ORM. ## Halt conditions - Refuse to report drift without both sides captured (`/tmp/db.sql` AND the ORM expected schema). - Refuse to flag a "ghost column" without confirming via `\d <table>` that it actually exists. - Halt if the target DB is prod — re-run against a restored snapshot. - Don't propose `db push` / destructive sync as the fix; propose a generated migration with the exact name. ## When to use - Before generating a new migration — drift corrupts autogenerate output. - After a prod incident where queries returned unexpected null/missing columns. - Weekly in CI against a restored backup. - After a hotfix that touched the DB out-of-band. ## Prerequisites - Read access to the target DB (DEV or STAGING — never prod directly). - The ORM CLI for your stack: `prisma`, `typeorm`, `alembic`, `drizzle-kit`, `sea-orm-cli`. - `psql` / `mysql` client for raw introspection. ## Procedure