- Home
- Skills
- Data & Databases
- DB Migration Safety Checker
Works with the AI Agents you already use
DB Migration Safety Checker
This skill audits your migration before it touches production: lock acquisition analysis, estimated execution time at your actual data volume, index build strategy (concurrent vs.
$9.99
DB Migration Safety Checker
Example session with this skill installed
Postgres 14 with Rails, rolling deploys. The orders table has about 80M rows (120 GB). I want to rename the status column to order_status and add a NOT NULL region column filled from shipping_country. Is this safe?
- Read your context and instructions
- Compiled the db migration safety
Not safe as a single migration. Both changes need an expand-contract sequence on an 80M row table.
Lock and rewrite analysis
| Change | Lock | Rewrite | Risk |
|---|---|---|---|
RENAME COLUMN | ACCESS EXCLUSIVE, brief | No | Old app pods fail mid rolling deploy |
ADD COLUMN region nullable | ACCESS EXCLUSIVE, brief | No | Low |
Backfill in one UPDATE | Row locks on all rows | Heavy WAL, bloat | High |
SET NOT NULL directly | ACCESS EXCLUSIVE + full scan | No | High |
Safe sequence
- Add
order_statusandregionas nullable columns. Setlock_timeout = '5s'. - Deploy code that writes both
statusandorder_status. - Backfill both columns in batches:
UPDATE orders SET order_status = status,
region = map_region(shipping_country)
WHERE id BETWEEN :start AND :end
AND order_status IS NULL;
Batches of 10k to 50k rows, a short pause between them.
4. ADD CONSTRAINT region_nn CHECK (region IS NOT NULL) NOT VALID, then VALIDATE CONSTRAINT, then SET NOT NULL (skips the scan on PG 12+).
5. Switch reads to order_status, deploy.
6. Stop writing status, then drop it in a later release.
Rollback plan
Steps 1 to 5 are reversible: old code still reads status. Only step 6 is one way, so take it after a full release cycle.
Next steps
- Define
map_regionand test it on a sample - Run the backfill on a staging copy first
Connects securely to your tools. The creator never sees your data.
About this skill
The migration ran instantly in staging and locked a 40-million-row table in production for nine minutes — because staging had 400 rows. This skill audits your migration before it touches production: lock acquisition analysis, estimated execution time at your actual data volume, index build strategy (concurrent vs. blocking), column default pitfalls, constraint validation timing, and the exact zero-downtime sequence if your migration needs one. It also writes the rollback script, because migrations that can't be undone shouldn't be run without one. Use it on every migration that touches a table with more than 10,000 rows, adds a NOT NULL column, drops anything, or runs during business hours. Give it your migration file and your production table sizes; it returns the risk assessment and the safe execution plan.
- Cannot verify actual production load or existing lock contention in real-time.
- Accuracy depends on providing the correct DB engine and version.
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 any payment.
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 4 months ago
Permissions
No special permissions declared or detected