# Safe Schema Migrations

> Evolve schemas without downtime: expand/contract (add -> backfill in batches -> switch -> drop) across separate deploys, lock-aware DDL (create indexes CONCURRENTLY, nullable-add-then-validate), reversibility, and ordered versioned migrations.

- Skill: `mcorbett51090/safe-schema-migrations` (Agent Skill)
- Install (CLI): `npx get-skill add mcorbett51090/safe-schema-migrations`
- Raw SKILL.md: https://api.skillmd.com/api/skills/mcorbett51090/safe-schema-migrations/raw
- Safety review: pending (external: skill-scanner PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: mcorbett51090 (https://skillmd.com/u/mcorbett51090)
- Updated: 2026-11-19
- Page: https://skillmd.com/skills/mcorbett51090/safe-schema-migrations

---


# Safe Schema Migrations

## Expand/contract
Add new (safely) -> **backfill in batches** -> dual-write/switch reads -> drop old. Across **separate deploys**. A rename = add-copy-switch-drop, not `ALTER RENAME` mid-traffic.

## Lock awareness
Volatile-default add, type change, or `SET NOT NULL` can lock the table. Use: nullable add + batched backfill + `ADD CONSTRAINT ... NOT VALID` then `VALIDATE`; create indexes **CONCURRENTLY**.

## Reversible + ordered
Every migration has a down path / tested rollback. Versioned, ordered, never edit a shipped migration. Sequence with `devops-cicd/release-engineer`.

