- Home
- Skills
- Data & Databases
- Zero-Downtime DB Migrations: Ship Schema Changes Safely
Works with the AI Agents you already use
Zero-Downtime DB Migrations: Ship Schema Changes Safely
Plans and writes expand/contract database migrations that never lock tables or break running code. Checks lock levels, backfills in batches, adds rollback steps. Postgres, MySQL, Prisma, Django, Rails, Alembic.
$7.99
Zero-Downtime DB Migrations: Ship Schema Changes Safely
Example session with this skill installed
Rename users.fullname to display_name and make it NOT NULL. Postgres 15, Prisma, 8M rows.
- Read your context and instructions
- Compiled the zero-downtime db migrations
Risk: a direct rename breaks the running app version; SET NOT NULL on 8M rows takes an ACCESS EXCLUSIVE lock during a full scan. Plan it as 4 releases.
| Phase | Schema | App code | Rollback |
|---|---|---|---|
| A Expand | ADD COLUMN display_name text | none | drop column |
| B Migrate | none | dual-write both columns + batch backfill | stop job |
| C Switch | CHECK (display_name IS NOT NULL) NOT VALID → VALIDATE → SET NOT NULL | read display_name | revert reads |
| D Contract | DROP COLUMN fullname | remove old field | (one release later) |
Phase A migration (prisma/migrations/20261117_add_display_name/migration.sql)
SET lock_timeout = '3s';
ALTER TABLE users ADD COLUMN display_name text;
Backfill job (scripts/backfill-display-name.ts), idempotent and safe to re-run:
for (;;) {
const n = await prisma.$executeRaw`
UPDATE users SET display_name = COALESCE(fullname, '')
WHERE id IN (SELECT id FROM users WHERE display_name IS NULL ORDER BY id LIMIT 5000)`;
if (n === 0) break;
await sleep(200);
}
App dual-write (Phase B) keeps new rows filled while the job runs.
Phase C: VALIDATE CONSTRAINT only takes a SHARE UPDATE EXCLUSIVE lock, so writes continue; then SET NOT NULL is instant because PG uses the validated check.
Verify: SELECT count(*) FROM users WHERE display_name IS NULL; must be 0 before Phase C.
Next: ship Phase A today, deploy dual-write, run backfill off-peak.
Connects securely to your tools. The creator never sees your data.
About this skill
Plans and writes expand/contract database migrations that never lock tables or break running code. Checks lock levels, backfills in batches, adds rollback steps. Postgres, MySQL, Prisma, Django, Rails, Alembic.
How it works
- Inspect first
- Classify each operation
- Write the plan as phased releases
- Guardrails in every migration
- Output
Use it when
You say add a column, rename a column, drop a table, change a type, add an index or NOT NULL on a big table, write a migration for production, or "will this migration lock the table".
Why this one
- Runs real checks instead of generic advice
- Concrete output: files, tables and next steps you can act on today
- Works with Claude Code, Codex CLI, Cursor, Gemini CLI and any SKILL.md agent
More by Ignasi: Frontend Design Pro, Security Audit, Cut Agent Token Costs.
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Data & Databases.
Requires Postgres 11+ or MySQL 8.0+. Large backfills are generated as separate application scripts or jobs, not part of the primary migration transaction.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed today