Agent skill · software engineering · pedronauck
drizzle-safe-migrations
Plan safe Drizzle backfills, enum/check/default changes, constraint tightening, migration ordering, and rollback. Excludes other ORMs, query optimization, and new-schema design.
Why this skill is useful
Adds a comprehensive migration workflow with specific commands and patterns for Drizzle that are not commonly found in public documentation.
What it needs
Requires bun installed locally. About 2k tokens when loaded. Last updated 2026-08-01. 564 stars on the source repository.
What this skill does
Drizzle Safe Migrations Overview Use this skill to run database migrations in a way that is auditable, deployment-safe, and consistent with Drizzle's migration model. Core Rules Generate schema migrations with the existing project script and package manager; bun run db:generate below is an example, not a required script name. Never hand-edit generated schema migration files. Generate data backfills as custom migrations (bun run db:generate -- --custom --name <name>) and edit only that custom SQL file. Apply data normalization before tightening constraints. Keep one-off data fixes in migration history, not as hidden runtime logic, unless an emergency hotfix requires temporary mitigation. Workflow 1. Classify the change: schema-only: only column/table/index/default changes. data+schema: old rows must be transformed before new constraints/defaults. 2. For data+schema, create custom migration first: bun run db:generate -- --custom --name <descriptivename> Add idempotent backfill SQL. 3. Generate schema migration second: bun run db:generate 4. Verify migration ordering in drizzle/meta/journal.json: backfill migration index must be lower than constraint-tightening migration index. 5. Verify generated SQL and snapshots: backfill migration contains only intended data change. schema migration contains constraint/default/type changes. 6. Run the owning migration suite against existing-data and fresh-install cases, plus required project gates. Reuse current evidence; unrelated backend suites are not an additional skill gate. 7. Record material rollout risks and recovery steps when applicable: expected data transformations, lock-risk areas, rollback strategy. Backfill Requirements Use restrictive WHERE clauses. Prefer idempotent updates (UPDATE ... WHERE status = 'legacyvalue'). Do not mix unrelated DDL/DML in the same migration. Keep SQL explicit and minimal. Constraint Tightening Pattern When removing allowed values (enum/check): 1. …
How to use it
Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:
@skills pedronauck/drizzle-safe-migrations