Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIDeepSeekDeepSeekMuseMuse+22 more

    Zero-Downtime SQL Migration Linter

    by Saizul Amin

    1

    Plan and lint zero-downtime database migrations for PostgreSQL and MySQL to prevent locking large tables.

    $8

    Secure checkout via Stripe

    Money-back guarantee

    Converts to your local currency at checkout

    Security scanned
    Zero-Downtime SQL Migration Linter

    Zero-Downtime SQL Migration Linter

    Example session with this skill installed

    Review this PostgreSQL migration before we run it on production. Will anything lock tables or cause downtime?

    • Read your context and instructions
    • Compiled the zero-downtime sql migration

    I ran the bundled script from the safe-migrations skill and reviewed its findings.

    Demo data: this is the real, unedited output of the skill's script on the test fixture that ships with its source repo.

    Script output

    migration-lint: 9 high, 7 medium (1 file(s))
    HIGH    tests/fixtures/safe-migrations/pg_bad.sql:3  create_index_not_concurrently  CREATE INDEX on orders blocks all writes until the index is built
            fix: CREATE INDEX CONCURRENTLY ... (outside a transaction); if it fails, DROP INDEX CONCURRENTLY the INVALID index and retry
    MEDIUM  tests/fixtures/safe-migrations/pg_bad.sql:3  missing_lock_timeout  no lock timeout set before locking orders
            fix: SET lock_timeout = '5s'; at the top (and retry on failure) so a blocked ALTER does not queue every query behind it
    HIGH    tests/fixtures/safe-migrations/pg_bad.sql:4  concurrently_in_transaction  CONCURRENTLY cannot run inside a transaction block (the migration will fail)
            fix: run it in its own non-transactional migration (Rails: disable_ddl_transaction!, Django: atomic = False, Flyway: separate script, Alembic: autocommit_block())
    HIGH    tests/fixtures/safe-migrations/pg_bad.sql:5  add_column_volatile_default  ADD COLUMN with volatile DEFAULT gen_random_uuid() rewrites orders under ACCESS EXCLUSIVE
            fix: add the column without a default (or with a constant), backfill in batches, then SET DEFAULT
    HIGH    tests/fixtures/safe-migrations/pg_bad.sql:6  add_column_not_null_no_default  ADD COLUMN ... NOT NULL without DEFAULT fails if orders has rows
            fix: add it nullable (or with a constant DEFAULT), backfill, then add NOT NULL via a NOT VALID check constraint
    HIGH    tests/fixtures/safe-migrations/pg_bad.sql:7  alter_column_type  changing a column type on orders rewrites the table and its indexes under ACCESS EXCLUSIVE
            fix: add a new column, dual-write, backfill in batches, swap; (varchar(n) -> larger n or text is metadata-only)
    MEDIUM  tests/fixtures/safe-migrations/pg_bad.sql:8  set_not_null  SET NOT NULL scans all of orders while holding ACCESS EXCLUSIVE
            fix: ADD CONSTRAINT c CHECK (col IS NOT NULL) NOT VALID; VALIDATE CONSTRAINT c; then SET NOT NULL (PostgreSQL 12+ skips the scan); DROP the check
    MEDIUM  tests/fixtures/safe-migrations/pg_bad.sql:9  add_fk_without_not_valid  adding a foreign key validates every row of orders while locking both tables
            fix: ADD CONSTRAINT ... FOREIGN KEY ... NOT VALID; then in a separate step ALTER TABLE ... VALIDATE CONSTRAINT ...
    MEDIUM  tests/fixtures/safe-migrations/pg_bad.sql:10  add_check_without_not_valid  adding a CHECK constraint scans orders under ACCESS EXCLUSIVE
            fix: ADD CONSTRAINT ... CHECK (...) NOT VALID; then VALIDATE CONSTRAINT in a separate step
    MEDIUM  tests/fixtures/safe-migrations/pg_bad.sql:11  add_unique_constraint  ADD UNIQUE builds an index on orders while blocking writes
            fix: CREATE UNIQUE INDEX CONCURRENTLY idx ...; then ADD CONSTRAINT c PRIMARY KEY/UNIQUE USING INDEX idx
    HIGH    tests/fixtures/safe-migrations/pg_bad.sql:12  rename_column  renaming a column breaks every running app instance that uses the old name
            fix: expand/contract: add the new name, write both, backfill, switch reads, drop the old one later
    MEDIUM  tests/fixtures/safe-migrations/pg_bad.sql:13  drop_column  DROP COLUMN orders.legacy_flag: running code (and ORM caches) that select it will fail
            fix: first deploy code that ignores the column (Rails: ignored_columns), then drop; take a backup - this is irreversible
    HIGH    tests/fixtures/safe-migrations/pg_bad.sql:14  backfill_in_migration  UPDATE without WHERE inside a schema migration: one long transaction holding row locks (and replica lag)
            fix: run backfills separately in batches of 1-10k rows by primary key range, committing each batch (see references/patterns.md)
    MEDIUM  tests/fixtures/safe-migrations/pg_bad.sql:15  drop_index_not_concurrently  DROP INDEX takes an ACCESS EXCLUSIVE lock on the table
            fix: DROP INDEX CONCURRENTLY (outside a transaction)
    HIGH    tests/fixtures/safe-migrations/pg_bad.sql:16  drop_table  DROP TABLE order_archive: irreversible, and running code that still reads it will fail
            fix: deploy code that no longer uses the table first; take a backup; consider renaming it and dropping in a later release
    HIGH    tests/fixtures/safe-migrations/pg_bad.sql:17  vacuum_full  VACUUM FULL rewrites the table under ACCESS EXCLUSIVE
            fix: use pg_repack or pg_squeeze for online compaction
    

    Next steps

    1. Rewrite each flagged statement with the safe pattern shown.
    2. Run the migration on a staging copy with production-size data.
    3. Set lock_timeout and deploy in small steps.

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

    About this skill

    Migrations on large production tables often lead to lock contention, downtime, or failed deployments. This skill provides a linter and planning framework to execute schema changes without blocking traffic or breaking active application instances.

    What it does

    • Static Analysis scans migration SQL for dangerous operations like table rewrites, blocking locks, and destructive drops.
    • Pattern Injection recommends zero-downtime alternatives such as NOT VALID constraints and CONCURRENTLY index creation.
    • Lock Management guides the placement of lock_timeout/lock_wait_timeout to prevent migration queues from stalling your database.
    • Lifecycle Planning generates multi-step expand-and-contract plans for complex renames or type changes.
    • Batch Backfilling provides patterns for data migrations that avoid long-running transactions and replication lag.

    How it works

    1. Extract SQL from your ORM (Rails, Django, Prisma, etc.) or provide raw .sql files.
    2. Run Linter using the provided migration_lint.py to identify high-risk statements based on table size and engine version.
    3. Apply Patterns to replace risky commands with non-blocking equivalents found in the reference library.
    4. Sequence Deploys by following a numbered release plan that coordinates schema changes with application code updates.

    Frameworks & tools

    Supports PostgreSQL and MySQL/MariaDB. Works with migrations from Rails, Django, Laravel, Prisma, Flyway, Liquibase, Alembic, Knex, and golang-migrate.

    Why this beats prompting it yourself

    Generic LLMs often suggest standard ALTER TABLE commands that work on small dev sets but lock large production tables. This skill enforces specific database-level safety flags and multi-release workflows that prevent site outages.

    Use cases

    • Adding a NOT NULL column to a table with millions of rows.
    • Renaming or changing the data type of a column in a high-traffic table.
    • Creating indexes on busy tables without interrupting concurrent writes.
    • Automating migration safety checks in a CI/CD pipeline using JSON output.

    Known limitations

    Does not perform index selection or query optimization. Logic assumes a Python 3.8+ environment for the linter script. Cannot execute migrations directly on your production database.


    Open source: saizul/sql-database-skills on GitHub (MIT licence, by Saizul Amin).

    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.

    Linter requires Python 3.8+. Requires generated SQL from ORMs rather than reading native DSLs (ActiveRecord, Eloquent). Does not perform query or index optimization.

    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

    This skill acts as a safety layer for production databases, identifying SQL commands that would cause table locks or downtime and suggesting non-blocking alternatives like concurrent indexing and multi-step schema changes.

    The skill includes the `migration_lint.py` script, a library of zero-downtime migration patterns, and a framework for generating multi-step 'expand-and-contract' deployment plans.

    Yes, it is designed to ingest SQL exported from popular ORMs like Prisma, Django, and Rails, as well as raw SQL files from tools like Flyway or Liquibase.

    No, for security reasons, the skill analyzes your SQL code and provides a safe execution plan; it does not require or accept direct access to your production database credentials.

    While it works with standard LLMs, it is optimized for agents with file-system access (to run the linter script) and CI/CD integration capabilities for automated pipeline checks.

    The linter specifically checks for engine-specific risks like table rewrites in PostgreSQL and metadata locks in MySQL, providing tailored advice for each platform's locking behavior.

    New in Data & Databases