From holocron
Safe schema-migration patterns for systems under live traffic — expand/contract, backfill, double-write, shadow-read, online DDL. Use when authoring, reviewing, or sequencing a migration that can't take a maintenance window.
How this skill is triggered — by the user, by Claude, or both
Slash command
/holocron:migration-patternsThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Assume: the service is running, writes are arriving, you cannot take a maintenance window. Most production migrations live here.
Assume: the service is running, writes are arriving, you cannot take a maintenance window. Most production migrations live here.
Never couple a schema change to a code change in the same deploy. They fail independently, and you need each to be reversible independently.
The safe three-phase dance for any non-trivial change:
Each phase is a separate deploy. Each is independently revertable.
ALTER TABLE ... ADD COLUMN ... NULL. No lock (or brief, depending on engine).NOT NULL with no default on a large table — full-table rewrite, long lock. Use a default (cheap if metadata-only in your engine) or expand/migrate/contract: add nullable → backfill → add NOT NULL constraint.ALTER TABLE ... RENAME COLUMN while code is live. Callers break.CREATE INDEX CONCURRENTLY — no table lock. Monitor for failure.ALGORITHM=INPLACE, LOCK=NONE.CREATE INDEX on a hot table without CONCURRENTLY / online algorithm.NOT VALID (Postgres) so new rows are checked.VALIDATE CONSTRAINT later during low traffic.UPDATE ... WHERE condition on the whole table in one shot. It will bite.Sketch:
-- in a loop, with checkpointing and sleep
UPDATE users
SET email_lower = LOWER(email)
WHERE id > $last_id
AND id <= $last_id + 10000
AND email_lower IS NULL;
When writers must update both old and new:
Before switching reads:
Every migration has a reverse. Write both up and down migrations. For destructive ops (drops, renames), the reverse might be "restore from backup" — state that explicitly, and get a snapshot before you run it.
DELETE FROM ... WHERE ... to "clean up" at scale — use batched archival instead.CREATE INDEX without CONCURRENTLY on a live Postgres table — locks writes.SELECT * in backfill queries — read only what you need.npx claudepluginhub atuljha23/holocron --plugin holocronGuides creation, editing, and verification of skills for AI coding agents using test-driven development with subagent scenarios. Use when authoring or debugging skills.