Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIMuseMuseDotsDots+21 more

    Zero-Downtime Migrations for PostgreSQL and MySQL

    1

    **The problem.** Coding agents write migrations that pass every test and then take production down.

    $12

    Secure checkout via Stripe

    Money-back guarantee

    Converts to your local currency at checkout

    Security scanned
    Zero-Downtime Migrations for PostgreSQL and MySQL

    Zero-Downtime Migrations for PostgreSQL and MySQL

    Example session with this skill installed

    Add a required tenant_id column to our orders table (about 180 million rows, PostgreSQL 15, Rails 7) with a foreign key to tenants and an index, and backfill it from customers.tenant_id.

    • Read your context and instructions
    • Compiled the zero-downtime migrations

    Example session (illustrative).

    Facts gathered: PostgreSQL 15.6; orders is 212 GB, ~180M rows, ~900 writes/s; Rails 7.1 migrations run in a transaction by default; deploys are rolling.

    Plan (6 steps, each its own deploy or job; nothing applied):

    #Ships asSQL / changeLockCompatible with
    1migrationADD COLUMN tenant_id bigint (nullable, no default)ACCESS EXCLUSIVE, metadata only, lock_timeout 3sold code
    2migration, disable_ddl_transaction!add_index :orders, :tenant_id, algorithm: :concurrentlySHARE UPDATE EXCLUSIVE, ~25 min est.old code
    3migrationADD CONSTRAINT orders_tenant_fk FOREIGN KEY ... NOT VALIDbrief SHARE ROW EXCLUSIVE on both tablesold code
    4code deploymodel sets tenant_id on create/update (dual-write)noneboth
    5jobbatched backfill WHERE id >= :lo AND id < :lo + 5000 AND tenant_id IS NULL, pause if replay_lag > 5 srow locks per batchboth
    64 migrations, one transaction each(a) VALIDATE CONSTRAINT orders_tenant_fk; (b) add CHECK (tenant_id IS NOT NULL) NOT VALID; (c) validate it; (d) SET NOT NULL (no scan on PG 12+) and drop the CHECKSHARE UPDATE EXCLUSIVE for the scans; brief ACCESS EXCLUSIVE for (b) and (d), lock_timeout 3snew code

    Flagged in review: the first draft used null: false, default: ... with a subquery default, which is not allowed and would have needed a rewrite anyway; add_index without algorithm: :concurrently, which would have blocked writes for the whole build; and the CHECK added and validated in one transaction, which would have held ACCESS EXCLUSIVE for the whole validation scan.

    Rollback: steps 1-3 have down migrations (DROP INDEX CONCURRENTLY, drop constraint, drop column). Step 5 is re-runnable; stop the job to roll back. Step 6 is reversible (DROP NOT NULL). If step 2 fails, check pg_index.indisvalid and drop the INVALID index before retrying.

    Handed to you: 7 migration files, the backfill job, and this plan. Nothing was run against any database.

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

    About this skill

    The problem. Coding agents write migrations that pass every test and then take production down. CREATE INDEX without CONCURRENTLY blocks writes for minutes. ALTER TABLE ... SET NOT NULL scans a 200 GB table under an exclusive lock. A one-line RENAME COLUMN breaks every app server still running the old code. Even an "instant" ALTER can stall all traffic while it waits in the lock queue behind one long-running query. None of this shows up on a laptop database with 50 rows.

    What the agent does with this skill.

    • Checks the database version, table size and migration tool first, because the safe answer changes at PostgreSQL 11 and 12 and MySQL 8.0.12 and 8.0.29.
    • Splits risky changes into expand / dual-write / backfill / switch reads / contract steps, each compatible with the old and the new app version, and says which deploy each step ships in.
    • Replaces locking operations with safe equivalents: CREATE INDEX CONCURRENTLY (and cleanup of INVALID indexes), NOT VALID + VALIDATE CONSTRAINT, the PG 12+ CHECK trick for SET NOT NULL, UNIQUE USING INDEX, new-column-plus-trigger for type changes and renames, ALGORITHM=INSTANT / INPLACE, LOCK=NONE on MySQL.
    • Adds lock_timeout / statement_timeout (or MySQL lock_wait_timeout) so a blocked migration fails fast instead of queuing the whole site behind it.
    • Writes backfills as idempotent, resumable, primary-key batches that watch replica lag, outside the migration transaction.
    • Knows how Rails, Django, Alembic and Prisma wrap migrations in transactions and how to opt out for concurrent index builds.
    • Runs a pre-merge checklist and writes a per-step rollback plan, marking one-way steps explicitly.
    • Never runs anything against production. It produces the files and the plan; a human applies them.

    Who it's for. Teams that let Claude Code, Cursor, Codex CLI or similar agents touch application code that ships database migrations, and reviewers who want agent-written migrations to arrive already safe.

    Requirements. Any agent that supports SKILL.md skills. A PostgreSQL (primary focus) or MySQL/InnoDB project. No extra software, database access optional (read-only inspection only, when you grant it). Works with or without AgentHarness.

    Supports only PostgreSQL and MySQL. Does not execute SQL directly. Requires manual entry of table stats for accurate lock duration estimates. Multi-step migrations require multiple deployments.

    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 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 17 days ago

    Requires

    PostgreSQL or MySQL
    Migration tool

    Permissions

    No special permissions declared or detected

    Listed17 days ago

    What's inside

    Frequently Asked Questions

    No. The skill forbids running migrations, DDL or backfills against production or any shared environment. It writes the migration files and a step-by-step plan with lock levels, timings and rollback actions; a human applies them. With your permission it may run read-only queries such as `SELECT version()` or `pg_stat_user_tables` to size the work.

    PostgreSQL is the primary target, with version-specific rules called out (for example, fast `ADD COLUMN ... DEFAULT` for non-volatile defaults from PostgreSQL 11, and scan-free `SET NOT NULL` via a validated CHECK from PostgreSQL 12). MySQL/InnoDB differences are covered: non-transactional DDL, `ALGORITHM=INSTANT` and `INPLACE, LOCK=NONE`, metadata-lock timeouts, and when to reach for gh-ost or pt-online-schema-change.

    Rails (`disable_ddl_transaction!`, `algorithm: :concurrently`), Django (`atomic = False`, `AddIndexConcurrently`), Alembic (`autocommit_block()`, `postgresql_concurrently=True`) and Prisma (hand-edited `--create-only` migrations). The guidance is SQL-first, so it applies to any tool that lets you run raw SQL.

    No. It is a concrete playbook: which statement takes which lock, the exact safe replacement SQL, how to detect and clean up an INVALID index after a failed concurrent build, how to size backfill batches against replica lag, and a merge checklist the agent checks the migration against.

    No. The skill is self-contained and works in any agent that supports SKILL.md skills. AgentHarness is a separate open-source gate you can use alongside it.

    New in Data & Databases