- Home
- Skills
- Data & Databases
- DB Migration Safety Auditor
DB Migration Safety Auditor
Audit SQL, Rails, Django, and Prisma migrations for blocking locks, data loss, and deployment breaking changes.
$4.29
Works with the AI Agents you already use
DB Migration Safety Auditor
Example session with this skill installed
Review this Rails migration adding a foreign key: add_reference :orders, :users, foreign_key: true, index: false. The orders table has 50 million rows.
- Read your context and instructions
- Compiled the db migration safety
I have reviewed the migration for orders. While the syntax is correct, this will cause a significant blocking lock on a 50M-row table.
Migration Review — orders
| Risk Level | Type | Finding | Impact |
|---|---|---|---|
| Blocking | Table Lock | add_reference :orders, :users | Adding a foreign key constraint requires a full table scan to validate existing data, locking the orders table for the duration. |
| Blocking | Index Lock | add_index :orders, :user_id | If you later add the index manually, a standard add_index will lock writes to orders. |
| Data-risk | Constraint | foreign_key: true | Validation will fail if there are orphaned user IDs in the orders table. |
Safer approach:
To avoid a production outage, split this into three steps:
- Add the column without the constraint:
add_column :orders, :user_id, :bigint. - Add the index concurrently (PostgreSQL):
add_index :orders, :user_id, algorithm: :concurrently. - Add the foreign key without validation, then validate it separately:
add_foreign_key :orders, :users, column: :user_id, validate: false
# In a separate migration
validate_foreign_key :orders, :users
Next steps
- Verify if any
ordersrows containuser_idvalues that do not exist in theuserstable. - Confirm you are running PostgreSQL to use the
concurrentlyalgorithm. - Schedule the
validate_foreign_keystep for a lower-traffic window.
Connects securely to your tools. The creator never sees your data.
About this skill
The problem
Migrations that run instantly on a local machine can take production tables offline for minutes. Standard AI agents focus on schema correctness but ignore how databases execute changes under load or during rolling deploys.
What it does
- Scans migration files for blocking locks, non-concurrent indexes, and unsafe type changes.
- Identifies backward-incompatible changes that break blue-green deployments.
- Detects irreversible operations like empty downgrades or lossy retypes.
- Provides concrete "expand and contract" rewrite strategies for high-risk operations.
Frameworks & tools
Supports raw SQL, Ruby on Rails (ActiveRecord), Python (Django, Alembic), and TypeScript (Prisma). Works with PostgreSQL and MySQL engines.
Why this beats prompting it yourself
Generic prompts often miss the multi-step nature of safe migrations. This skill applies a specific risk rubric to distinguish between safe changes on small tables and outage-causing locks on high-traffic ones, providing the actual code for the fix.
Use cases
- Reviewing PRs that modify schema files or add new migration scripts.
- Auditing a migration plan for a table with millions of rows.
- Ensuring zero-downtime compatibility for rolling application updates.
- Validating that all database changes have a functional rollback path.
Known limitations
Does not audit schema design or naming conventions. Requires manual input or inference regarding table row counts to determine final lock severity.
Does not audit schema design aesthetics or normalization choices. Lock severity estimates require the user to provide approximate table row counts.
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 2 months ago
Requires