- Home
- Skills
- Data & Databases
- Migration Guard
Migration Guard
Analyze database migrations for locking risks, downtime, and data loss before they hit production.
$19
Works with the AI tools you already use
Migration Guard
Example session with this skill installed
I just added a migration to add a NOT NULL constraint to the users table in my Rails app. Is this safe to deploy to our production Postgres DB?
- Read your context and instructions
- Compiled the migration guard
- Generated the document
I have reviewed 20231027120000_add_not_null_to_users_email.rb. Adding a NOT NULL constraint to an existing column in PostgreSQL requires a full table scan while holding an SHARE UPDATE EXCLUSIVE lock, which will block writes on a large table.
Migration Risk Report
| Operation | Severity | Risk Type | SQL Equivalent |
|---|---|---|---|
change_column_null | HIGH | Table Scan / Lock Contention | ALTER TABLE "users" ALTER COLUMN "email" SET NOT NULL; |
Analysis
PostgreSQL must verify that no null values exist before applying the constraint. On a large users table, this scan can take significant time. Because this migration runs in a transaction, it holds the lock for the duration of the scan, potentially causing a connection pile-up.
Safe Rewrite (Expand/Contract Pattern)
To deploy this safely, you should split this into three steps across two deployments.
Step 1: Add a Check Constraint (Invalid)
This adds the constraint without validating existing rows, avoiding the long lock.
class AddEmailNotNullConstraint < ActiveRecord::Migration[7.0]
def change
add_check_constraint :users, "email IS NOT NULL", name: "email_is_not_null", validate: false
end
end
Step 2: Validate the Constraint
Run this in a separate migration. The scan is performed, but it does not block reads or writes.
class ValidateEmailNotNullConstraint < ActiveRecord::Migration[7.0]
def change
validate_check_constraint :users, name: "email_is_not_null"
end
end
Step 3: Finalize (Optional)
Once validated, you can safely set the actual NOT NULL column property as it is now a metadata-only change.
Next steps
- Replace the current migration with the "Step 1" code block.
- Verify if there are any existing
NULLvalues in theemailcolumn before running Step 2. - Apply a
statement_timeoutto your migration runner for added safety.
migration-guard-1.pdf
PDF · document
Example file from a real run - the skill writes it into your workspace.
Connects securely to your tools. The creator never sees your data.
What you get
About this skill
The problem
Schema migrations are a leading cause of production outages. A single ALTER TABLE on a hot table can block all incoming queries, exhaust connection pools, and take down an entire application in seconds.
What it does
- Analyzes migration files for
ACCESS EXCLUSIVElocks and head-of-line blocking risks. - Detects operations that force full table rewrites or long-running scans on large datasets.
- Identifies breaking changes where old application code will fail after the schema lands.
- Flags destructive operations like
DROP COLUMNorTRUNCATEthat lack a rollback path. - Generates per-operation risk reports with severity levels from Low to Critical.
Frameworks & tools
Supports PostgreSQL and MySQL/MariaDB. Compatible with ActiveRecord (Rails), Django, Alembic (SQLAlchemy), Prisma, TypeORM, Sequelize, Knex, Ecto, Flyway, and Liquibase.
Why this beats prompting it yourself
Generic LLMs often miss the nuanced locking behavior differences between database engines or specific ORM quirks. This skill uses dedicated reference sets for Postgres and MySQL lock matrices to ensure rewrites actually work in production environments.
Use cases
- Reviewing Pull Requests that introduce database schema changes.
- Refactoring blocking migrations into safe expand-contract patterns.
- Planning batch backfills for multi-million row tables.
- Auditing legacy migrations for missing down/rollback paths.
Known limitations
Cannot access live database statistics like real table sizes or current lock contention. Row-level security and complex triggers require manual review.
How to install
Works the same in every agent - Claude, Cursor, Codex, Copilot and 20+ more.
- 1
Download the ZIP
Free skills download straight away. Paid skills unlock right after purchase.
- 2
Unzip into your skills folder
Every agent reads skills from one folder on your machine. Drop the unzipped folder in there.
- 3
Ask your agent to use it
Restart the agent if it was already running. It picks the skill up automatically - no config needed.
Skills folder by agent
Click the path to copy it. Create the folder if it does not exist yet.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill passes our trust checks below.
Security scanned
Passed our 8-point scan before listing
Fresh listing
Recently published to Agensi
30-day refund
Not a fit? Get your money back
Trust & safety
Security scanned
Verified clean 5 days ago
- Passed all security checks, Safe to install