Use when changing libs/database/src/schema.ts, adding Drizzle migrations, debugging drizzle-kit drift, or deciding between auto-generated and custom SQL migrations. Includes the post-#867 baseline-reset rule.
71
86%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
View guide
Passed
No findings from the security scan
Operational guide for MoltNet database migrations.
libs/database/src/schema.tspnpm db:generatelibs/database/drizzle/libs/database/src/schema.tspnpm db:generatepnpm db:migrate:run or rebuild local Docker from scratchIf pnpm db:generate in a clean tree produces unexpected SQL, stop and assume
drift until proven otherwise.
Use pnpm db:generate when the change is representable in Drizzle:
Use pnpm exec drizzle-kit generate --custom --name <name> when the change is
not representable cleanly:
Custom SQL is allowed, but metadata must stay in sync.
If a custom migration introduces or changes a table, column, index, or
constraint that schema.ts also knows about, do one of these immediately:
schema.ts and follow up with an auto-generated migration that
brings the snapshot chain back in sync.Do not leave a raw SQL structural change unreflected in snapshots. That is how
future pnpm db:generate runs start proposing bogus renames and recreations.
meta/*_snapshot.json id and prevId must form a valid chainpnpm db:generate on a clean tree should be a no-opStrong drift signals:
owner_id, agent_keys, or human reappearing in snapshotspnpm db:generate runsIf the problem spans more than one or two migrations, do not keep patching old snapshots. Reset the baseline.
Reference: issue #867.
pg_dump --schema-onlylibs/database/drizzle/*.sql and libs/database/drizzle/meta/*.jsonpnpm db:generate to create a fresh 0000_init.sqldrizzle.__drizzle_migrations instead of executing them on live datapnpm docker:resetNever try to surgically repair deep historical drift. Reset is cheaper and safer.
5daa9ca
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.