← ClaudeAtlas

pg-migratelisted

Enforce safe PostgreSQL migration practices. Use this skill when editing **/migrations/*.sql, **/migrate/*.sql, schema.sql, or when the user mentions migration, ALTER TABLE, DROP TABLE, ADD COLUMN, NOT NULL, RENAME COLUMN, CREATE INDEX, lock table, downtime, schema change, sqitch, golang-migrate, Flyway. Forbids destructive ops without explicit user approval, NOT NULL adds without default, blocking index creation on large tables, atomic renames, transaction-less migrations.
zhaojiannet/canon · ★ 1 · Web & Frontend · score 77
Install: claude install-skill zhaojiannet/canon
This skill enforces safe PostgreSQL migration practices. The rule: every migration runs on a live production database without downtime. If it cannot, **STOP** and ask first. Apply when editing any SQL file under `migrations/` (or equivalent migration tool path). For one-off data fixes that are not for production schema, mention it explicitly so this skill knows to relax. ## Core principles - **Always wrap in a transaction**: `BEGIN; ...; COMMIT;`. A failed step rolls back. Some migrations cannot run inside a transaction (`CREATE INDEX CONCURRENTLY`, `ALTER TYPE ... ADD VALUE`); put these in their own migration file. - **Idempotent guards**: `IF EXISTS` on `DROP`, `IF NOT EXISTS` on `CREATE`. A migration that fails halfway should be safe to retry. - **No long locks during business hours**: `ALTER TABLE` that rewrites the entire table (adding a `NOT NULL` column without a default before PG 11, changing column type) takes an `AccessExclusiveLock` and blocks reads. - **Never lose data without explicit approval**: `DROP TABLE`, `DROP COLUMN`, `TRUNCATE`, `DELETE` without `WHERE`, `ALTER TYPE ... DROP VALUE` are destructive. STOP and ask the user before writing them. ## Forbidden patterns - `DROP TABLE foo;` without `IF EXISTS` and without explicit user approval. - `TRUNCATE foo;` without explicit user approval. - `DELETE FROM foo;` without `WHERE`. This is functionally `TRUNCATE` and locks the table. - `ALTER TABLE foo ADD COLUMN bar text NOT NULL;` (no default). On a non-emp