modootoday/marketplace/pg-migration-safety
Claude Code and agent skill by modootoday/marketplace
- community
Checking that the SKILL.md file is still in the repository.
Review a PostgreSQL schema migration for production safety - which statements take locks that block reads or writes, how long they hold them, CONCURRENTLY and NOT VALID patterns, backfills in batches, lock and statement timeouts, and the deploy order between code and schema. Use before running a migration on a live Postgres database, or when a migration caused downtime. Not for ClickHouse or query tuning.
Install
npx vskill@latest install modootoday/marketplace/pg-migration-safetySKILL.md
The same SKILL.md was published earlier as modootoday/marketplace/pg-migration-safety.
Safe Postgres migrations
The risk in a migration is rarely the change itself; it is the lock it takes and every query queued behind that lock while it waits.
Statement by statement
| Change | Risk | Safer pattern | |
|---|---|---|---|
CREATE INDEX | blocks writes for the build | CREATE INDEX CONCURRENTLY (outside a transaction) | |
| Add column with a volatile default | rewrites the table on older versions | add without default, backfill, then set default | |
Add NOT NULL | full scan under a strong lock | add a CHECK (col IS NOT NULL) NOT VALID, VALIDATE it, then set not null | |
| Add foreign key | scans both tables under lock | add NOT VALID, then VALIDATE CONSTRAINT | |
| Change column type | usually rewrites the table | new column, dual write, backfill, switch, drop | |
| Drop column or table | code still reading it fails | stop reading in code first, deploy, then drop | |
| Rename | breaks running code | add new, migrate readers, remove old |
Locks and timeouts
Set lock_timeout (a few seconds) and statement_timeout for the migration session, so a migration that cannot get its lock fails fast instead of queuing every request behind it. Retry later rather than raising the timeout.
Backfills
In batches by primary key range with a pause between, outside the schema migration's transaction, and idempotent so it can be resumed.
Deploy order
Expand (additive schema), deploy code that works with both shapes, migrate data, contract (remove the old shape). Each step must be safe to roll back alone.
Output
Per statement: lock level, expected duration on this table's size, the safer rewrite, and the deploy step it belongs to. Then three process lines, each stated outright: the session lock_timeout and statement_timeout values and "retry later, do not raise them"; the expand, dual-shape deploy, data migration, contract order with each step safe to roll back alone, so a one-step deploy is refused when a statement needs two; and the backfill rule (primary key ranges, a pause between batches, idempotent, outside the migration transaction, with steps such as VALIDATE CONSTRAINT or CONCURRENTLY also outside any wrapping transaction).
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingplugins/platform-review/skills/pg-migration-safety/SKILL.md
Popularity
- 7-day trend score
- 5
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Grok Build (Cursor)
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/modootoday/marketplace/pg-migration-safety)