Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIDeepSeekDeepSeekMuseMuse+22 more

    SQL Migration Safety Check

    1

    Flags migration statements that lock tables or lose data, with a safer pattern for each. PostgreSQL and MySQL.

    $5

    Secure checkout via Stripe

    Money-back guarantee

    Converts to your local currency at checkout

    Security scanned
    SQL Migration Safety Check

    SQL Migration Safety Check

    Example session with this skill installed

    /sql-migration-safety-check migrations/002_add_status.sql --dialect postgres

    • Read your context and instructions
    • Compiled the sql migration safety

    Illustrative. The migration is invented; the report below is what the script prints for it.

    SQL MIGRATION SAFETY CHECK (1 file(s): 2 high, 4 medium, 2 info)
    
    examples/migrations/002_add_status.sql  [postgres, 6 statement(s)]
       HIGH   line 2    add-column-not-null-no-default
              ALTER TABLE orders ADD COLUMN status TEXT NOT NULL
              why: Fails on a table that already has rows (no value for existing rows) or forces a rewrite.
              safer: Add the column as nullable, backfill in batches, then add the NOT NULL rule (for PostgreSQL via a CHECK ... NOT VALID, VALIDATE, then SET NOT NULL).
       HIGH   line 7    update-delete-without-where
              UPDATE orders SET status = 'open'
              why: Touches every row in one statement: long locks, a big transaction, and no easy way back.
              safer: Add a WHERE and run in batches by key range; run a SELECT with the same WHERE first and check the count.
       MEDIUM line 3    add-column-volatile-default
              ALTER TABLE orders ADD COLUMN public_id UUID DEFAULT gen_random_uuid()
              why: A default that changes per row (random, uuid, sequence, clock) makes PostgreSQL rewrite the whole table under an exclusive lock.
              safer: Add the column with no default, backfill in batches, then set the default for new rows.
       MEDIUM line 4    constraint-without-not-valid
              ALTER TABLE orders ADD CONSTRAINT orders_customer_fk FOREIGN KEY (customer_id) REFERENCES customers(id)
              why: Checks every existing row while holding a lock.
              safer: ADD CONSTRAINT ... NOT VALID, then ALTER TABLE ... VALIDATE CONSTRAINT ... in a separate step.
       MEDIUM line 5    set-not-null
              ALTER TABLE orders ALTER COLUMN public_id SET NOT NULL
              why: Scans the whole table under an exclusive lock.
              safer: First ADD CONSTRAINT ... CHECK (col IS NOT NULL) NOT VALID, VALIDATE it, then SET NOT NULL (PostgreSQL 12 and later skips the scan).
       MEDIUM line 6    index-not-concurrent
              CREATE INDEX idx_orders_customer ON orders (customer_id)
              why: Builds the index while blocking writes to the table.
              safer: CREATE INDEX CONCURRENTLY ... (it cannot run inside a transaction block, so run it as its own migration step).
       INFO   line 1    no-lock-timeout
              (whole file)
              why: An ALTER TABLE that has to wait for a lock also makes every later query on that table wait behind it.
              safer: Start the migration with SET lock_timeout = '3s'; so it fails fast instead of queueing, and retry.
       INFO   line 1    schema-and-data-mixed
              (whole file)
              why: Schema changes and data changes in one file hold their locks together and are harder to roll back.
              safer: Split into one schema migration and one data migration (backfills in batches).
    
    Limits: this reads the SQL text only. It does not know your table sizes, your database version, your traffic or whether the migration tool wraps files in transactions, so a flagged statement may be fine on a small table and a clean file is not a promise. To silence a rule on one statement, put '-- migration-check: ignore RULE-ID' in a comment just before it, and say why. It never connects to a database and never runs the SQL.
    

    Next steps

    • Fix the high findings first; most have a safe two-step form.
    • Run the same statements against a copy of production data before the real run.

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

    About this skill

    Check migration files before they meet production. Give it a .sql file or a folder of migrations and it flags statements that are known to lock a table, rewrite it, break the application version that is still running, or destroy data: an index built without CONCURRENTLY, a NOT NULL column with no default, a column type change, a constraint without NOT VALID, a rename, a drop, an UPDATE or DELETE with no WHERE, a TRUNCATE, a MySQL ALTER with no stated algorithm, and more. Every finding comes with the file, the line, why it is risky and a safer pattern. Quoted strings, comments and function bodies are not read as statements, and one rule can be silenced on one statement with a comment that says why.

    What it reads and writes: only the .sql files you name; it writes nothing. It never connects to a database and never runs the SQL. No network connection, no environment variables, nothing to install.

    Honest limits: it reads SQL text only. It does not know your table sizes, your database version, your traffic or whether your migration tool wraps files in transactions, so a flagged statement can be fine on a small table and a clean file is not a promise. Unusual syntax can be missed. Needs Python 3.9+.

    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.

    Needs Python 3.9+. Reads SQL text only: no table sizes, version, traffic or transaction wrapping. A flagged statement can be fine on a small table; a clean file is not a promise.

    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.

    Trust & safety

    Security scan

    Security scan passed 15 days ago

    Software
    Python

    Permissions

    Terminal / Shell
    Read Files

    File Scopes

    <the
    .sql
    files
    or
    folder
    you
    name>

    Reads only the .sql files you name; it never connects to a database, never runs the SQL, makes no network connection and reads no environment variables. Statements such as DROP TABLE and TRUNCATE appear in the code only as patterns to detect.

    Listed15 days ago
    Updated13 days ago

    What's inside

    Frequently Asked Questions

    No. It never connects to a database and never runs the SQL. It reads the migration files as text.

    PostgreSQL and MySQL rules, plus generic rules (drops, renames, UPDATE or DELETE with no WHERE, TRUNCATE). SQLite and others get the generic rules. It guesses the dialect and prints what it guessed; you can set --dialect.

    Yes, on one statement: put '-- migration-check: ignore RULE-ID' in a comment just before it, with the reason.

    Yes: --fail-on high returns a non-zero exit code when a high finding exists.

    New in Data & Databases