Drizzle safe migrations

From pedronauck/skills · View interactive version

Drizzle safe migrations is an AI agent skill from the GitHub repository pedronauck/skills. Plan safe Drizzle backfills, enum/check/default changes, constraint tightening, migration ordering, and rollback. Excludes other ORMs, query optimization, and new-schema design.

How to use this skill

Skill file

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

Workflow

  1. Classify the change:
  1. For data+schema, create custom migration first:
  1. Generate schema migration second:
  1. Verify migration ordering in drizzle/meta/_journal.json:
  1. Verify generated SQL and snapshots:
  1. 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.
  2. Record material rollout risks and recovery steps when applicable:

Backfill Requirements

Constraint Tightening Pattern

When removing allowed values (enum/check):

  1. Backfill existing rows to valid target value.
  2. Update default to new value.
  3. Tighten check/enum constraint.

For large tables or strict uptime targets, evaluate staged constraint validation supported by the actual database and driver. PostgreSQL NOT VALID / VALIDATE CONSTRAINT applies only to supported constraint kinds.

Anti-Patterns

Reference

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.