modootoday/marketplace/pg-migration-safety

Claude Code and agent skill by modootoday/marketplace

Trust tier 3
  • community
Source check pending

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-safety

SKILL.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

ChangeRiskSafer pattern
CREATE INDEXblocks writes for the buildCREATE INDEX CONCURRENTLY (outside a transaction)
Add column with a volatile defaultrewrites the table on older versionsadd without default, backfill, then set default
Add NOT NULLfull scan under a strong lockadd a CHECK (col IS NOT NULL) NOT VALID, VALIDATE it, then set not null
Add foreign keyscans both tables under lockadd NOT VALID, then VALIDATE CONSTRAINT
Change column typeusually rewrites the tablenew column, dual write, backfill, switch, drop
Drop column or tablecode still reading it failsstop reading in code first, deploy, then drop
Renamebreaks running codeadd 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

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
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/modootoday/marketplace/pg-migration-safety/badge)](https://verified-skill.com/skills/modootoday/marketplace/pg-migration-safety)

Something wrong with this skill or its page? Tell us.