Migration Guard

    by Mojaik (싼타)

    1

    Analyze database migrations for locking risks, downtime, and data loss before they hit production.

    $19

    Secure checkout via Stripe

    Money-back guarantee

    Converts to your local currency at checkout

    Security scanned

    Works with the AI Agents 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

    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

    OperationSeverityRisk TypeSQL Equivalent
    change_column_nullHIGHTable Scan / Lock ContentionALTER 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

    1. Replace the current migration with the "Step 1" code block.
    2. Verify if there are any existing NULL values in the email column before running Step 2.
    3. Apply a statement_timeout to your migration runner for added safety.

    Connects securely to your tools. The creator never sees your data.

    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 EXCLUSIVE locks 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 COLUMN or TRUNCATE that 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 use

    1. 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. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 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.

    Frequently Asked Questions

    Migration Guard performs a deep static analysis of your migration files to identify operations that cause table locks, full rewrites, or breaking changes before they reach production. It prevents common outages caused by 'hot table' locks and provides specific warnings for destructive actions that lack a rollback path.

    It is compatible with all major ORMs including ActiveRecord, Django, Prisma, and Alembic, and supports both PostgreSQL and MySQL/MariaDB dialects. You can use it as a standalone reviewer or integrate it into your CI/CD pipeline via any AI agent platform that supports file-based analysis.

    While generic LLMs might miss engine-specific locking nuances, this skill utilizes specialized reference sets for Postgres and MySQL lock matrices. This ensures it catches subtle 'Access Exclusive' locks and head-of-line blocking risks that general-purpose AI models often overlook.

    Migration Guard provides a risk report for each operation, categorized by severity (Low to Critical), along with actionable suggestions for refactoring blocking migrations into safe 'expand-contract' patterns. You will receive the skill definition, configuration guides, and access to all future version updates for the logic engine.

    This skill performs static analysis of your code and does not require access to your production database or live statistics. Because it doesn't see real-time table sizes or current lock contention, it flags risks based on schema structure and best practices for the target engine.

    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.