# Migration Writer

> Write safe, reversible database migrations for this repo's conventions. Use for any schema change.

- Skill: `archive228/migration-writer` (Agent Skill)
- Install (CLI): `npx skillmds@latest add archive228/migration-writer`
- Raw SKILL.md: https://api.skillmd.com/api/skills/archive228/migration-writer/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: archive228 (https://skillmd.com/u/archive228)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/archive228/migration-writer

---

# Migration Writer
1. Read the current schema first. Match the repo's migration tool and naming (`NNN_<verb>_<noun>`).
2. Write BOTH up and down. A migration you can't reverse is a migration you can't deploy safely.
3. **Live-safe**: on a hot table, adding a NOT NULL column with no default, or an index without CONCURRENTLY, takes a blocking lock. Split into steps: add nullable → backfill → add constraint.
4. Backfill large tables in batches, not one statement.
5. Never edit an already-merged migration — add a new one.
Test with a dry-run before committing. Output the migration + the exact deploy order.

