← ClaudeAtlas

safe-migrationslisted

This skill should be used when the user mentions "migration", "schema change", "zero downtime", "add column", "alter table", "add index", "lock", "expand contract", "backfill", "ALTER COLUMN", "NOT NULL", "CREATE INDEX", or rewriting a DDL change to avoid downtime. It provides the expand-contract (parallel-change) methodology and a per-dialect catalog of which DDL operations take blocking locks and their safe alternatives.
ClaudeRegistry/marketplace · ★ 2 · API & Backend · score 68
Install: claude install-skill ClaudeRegistry/marketplace
# Safe Migrations ## Purpose Provide a standardized, static methodology for turning a hazardous schema migration into a safe, reversible, zero-downtime change, without a database connection. The core idea: most outages come from a DDL statement that takes a long-held **ACCESS EXCLUSIVE** (Postgres) or table-copy (MySQL) lock and blocks all traffic while it rewrites the table. The fix is almost always the same shape, so this skill encodes it once. ## The Expand-Contract (Parallel-Change) Principle Never change a schema object in place while the app runs. Instead, evolve in additive steps so old and new code both work at every moment: 1. **Expand**: add the new structure (nullable column, new index built concurrently, `NOT VALID` constraint) without touching existing behavior. 2. **Migrate**: backfill data in bounded batches; dual-write from the app so old and new stay consistent. 3. **Contract**: once all deploys read the new structure, remove the old one in a *later* deploy. Each step is independently deployable and reversible. A rename or type change is never one migration, it is a sequence spanning multiple deploys. ## The Golden Rules - Add columns **nullable**; never `NOT NULL DEFAULT <volatile>` in one shot on a large table. - Build indexes **concurrently** (Postgres) or **in place, lock-free** (MySQL); otherwise use an online-DDL tool. - Add constraints as **`NOT VALID`** first, then **`VALIDATE`** in a separate statement (short lock, then a scan that does not bloc