- Home
- Skills
- Data & Databases
- Migration Safety Gate
Migration Safety Gate
Catches the migration that silently drops your data or locks a production table.
$5.99
Migration Safety Gate
Example session with this skill installed
Review this PostgreSQL 14 migration for a table with 50M rows: ALTER TABLE orders ADD COLUMN status VARCHAR(255) DEFAULT 'pending' NOT NULL; ALTER TABLE orders ADD COLUMN metadata JSON;
- Read your context and instructions
- Compiled the migration safety gate
The migration was analyzed for PostgreSQL 14. Adding a column with a constant default is metadata-only in this version, but the second operation carries minor risks.
Verdict — GO WITH CONDITIONS
Findings
| # | Statement | Class | Severity | Impact | Fix |
|---|---|---|---|---|---|
| 1 | ADD COLUMN status | Locking | Note | Minimal on PG 11+ due to fast default. | Ensure no long-running transactions exist. |
| 2 | ADD COLUMN metadata | Locking | Warning | ACCESS EXCLUSIVE lock could block the queue. | Use a lock_timeout for the session. |
| 3 | Combined ops | Deploy | Warning | Total lock time increases with multiple DDLs. | Split into individual transactions. |
Rewritten Migration
-- Step 1: Set a short lock timeout to prevent queue pile-up
SET lock_timeout = '2s';
-- Step 2: Add columns (Fast in PG 14)
ALTER TABLE orders
ADD COLUMN status VARCHAR(255) DEFAULT 'pending' NOT NULL,
ADD COLUMN metadata JSON;
Pre-flight Checklist
- Verify Table Size:
SELECT pg_size_pretty(pg_total_relation_size('orders')); - Check Active Locks: Run
SELECT pid, state, query FROM pg_stat_activity WHERE wait_event_type = 'Lock';before running. - Transaction Check: Ensure no long-running analytical queries are holding
ACCESS SHARElocks on theorderstable.
Next steps
- Run the row count and lock check queries provided in the checklist.
- Apply the migration during a period of lower traffic to minimize the impact of the brief
ACCESS EXCLUSIVElock.
Connects securely to your tools. The creator never sees your data.
About this skill
The failure this catches
Most migrations that cause an outage look completely ordinary in review. The damage comes from four places, and a reviewer reading the file cannot see three of them.
The four checks
- Data destruction. Including the one nobody expects: many ORMs emit
DROP COLUMN+ADD COLUMNwhen they cannot express an in-place alter. The schema is correct afterwards and every row is null. - Locking and downtime. Which lock each statement takes, on your engine and version - PostgreSQL 11 and 14 differ materially, MySQL differs again. Including the lock-queue trap: a blocked
ALTER TABLEwaiting behind a long read blocks every subsequent query on that table, reads included. A 30-second migration becomes a total outage. - Backward compatibility. Only matters if old and new code run at once during deploy - so it asks, rather than assuming.
- Reversibility. And it says plainly whether your rollback restores the data or only the schema.
What you get back
A GO / GO WITH CONDITIONS / NO-GO verdict on the first line, a severity-ranked findings table, and - the part you actually want - the rewritten migration as runnable SQL, split into the separate deploys it really requires. Plus a pre-flight checklist: the exact queries to run for row counts and long-running transactions, and the lock_timeout to set.
Rules it holds to
It never approves a migration whose emitted SQL it has not seen. It never softens a blocker to a warning because the fix is inconvenient. Where the engine version is unknown it reports against the most restrictive plausible version and tells you which it assumed.
Requires emitted SQL for ORM migrations. Does not analyze query performance or index efficiency. User must provide table row counts and engine versions for accurate locking analysis.
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 3 months ago
Permissions
What's inside
Frequently Asked Questions
New in Data & Databases
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.