Skip to content
⭐ Featureddeployment

Migration Safety Review

Review SQL migrations for locking, downtime risk, backward compat, and data loss before they hit production.

/migration-safe

Install this skill

  1. 1. Copy the SKILL.md content (button above)
  2. 2. Create a folder for the skill:
    # Mac/Linux
    mkdir -p ~/.claude/skills/migration-safe
    
    # Windows (PowerShell)
    mkdir $env:USERPROFILE\.claude\skills\migration-safe
  3. 3. Save the content as ~/.claude/skills/migration-safe/SKILL.md
  4. 4. Restart Claude Code (or open a new session)
  5. 5. Type /migration-safe to invoke it
sqlmigrationspostgresdowntime

/migration-safe

Catch dangerous migrations before they hit production.

Usage

/migration-safe migrations/20260101_add_status.sql /migration-safe # last unapplied migration /migration-safe --all # all pending

What it checks

Locking

  • ALTER TABLE ADD COLUMN with default → table rewrite on Postgres < 11
  • ADD CONSTRAINT NOT NULL without NOT VALID first
  • Long-running indexes without CONCURRENTLY
  • ALTER COLUMN TYPE that requires full rewrite

Backward compat

  • Renaming or dropping columns still referenced by old app code
  • Type changes that break existing queries
  • Reordering enums (Postgres allows but ORMs often don't)

Data integrity

  • Missing NOT NULL defaults → rows with NULL after backfill
  • Foreign key cascades that could nuke unrelated data
  • Triggers that aren't transactional

Reversibility

  • Missing down migration
  • Down migration that loses data silently

Output

For each issue:

  • Severity (will break prod / risky / inefficient / minor)
  • What goes wrong (concrete: "5min downtime on tables > 1M rows")
  • Safe alternative (e.g. expand-and-contract pattern)

Rules

  • Adapt to the DB engine (Postgres / MySQL / SQLite — different gotchas)
  • For Postgres, prefer CREATE INDEX CONCURRENTLY, SET NOT NULL ... NOT VALID + VALIDATE
  • Suggest a multi-step rollout if a migration can't be safe in one shot