Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIDeepSeekDeepSeekMuseMuse+22 more

    Zero-Downtime DB Migrations: Ship Schema Changes Safely

    1

    Plans and writes expand/contract database migrations that never lock tables or break running code. Checks lock levels, backfills in batches, adds rollback steps. Postgres, MySQL, Prisma, Django, Rails, Alembic.

    $7.99

    Secure checkout via Stripe

    Money-back guarantee

    Converts to your local currency at checkout

    Security scanned
    Zero-Downtime DB Migrations: Ship Schema Changes Safely

    Zero-Downtime DB Migrations: Ship Schema Changes Safely

    Example session with this skill installed

    Rename users.fullname to display_name and make it NOT NULL. Postgres 15, Prisma, 8M rows.

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

    Risk: a direct rename breaks the running app version; SET NOT NULL on 8M rows takes an ACCESS EXCLUSIVE lock during a full scan. Plan it as 4 releases.

    PhaseSchemaApp codeRollback
    A ExpandADD COLUMN display_name textnonedrop column
    B Migratenonedual-write both columns + batch backfillstop job
    C SwitchCHECK (display_name IS NOT NULL) NOT VALID → VALIDATE → SET NOT NULLread display_namerevert reads
    D ContractDROP COLUMN fullnameremove old field(one release later)

    Phase A migration (prisma/migrations/20261117_add_display_name/migration.sql)

    SET lock_timeout = '3s';
    ALTER TABLE users ADD COLUMN display_name text;
    

    Backfill job (scripts/backfill-display-name.ts), idempotent and safe to re-run:

    for (;;) {
      const n = await prisma.$executeRaw`
        UPDATE users SET display_name = COALESCE(fullname, '')
        WHERE id IN (SELECT id FROM users WHERE display_name IS NULL ORDER BY id LIMIT 5000)`;
      if (n === 0) break;
      await sleep(200);
    }
    

    App dual-write (Phase B) keeps new rows filled while the job runs.

    Phase C: VALIDATE CONSTRAINT only takes a SHARE UPDATE EXCLUSIVE lock, so writes continue; then SET NOT NULL is instant because PG uses the validated check.

    Verify: SELECT count(*) FROM users WHERE display_name IS NULL; must be 0 before Phase C.

    Next: ship Phase A today, deploy dual-write, run backfill off-peak.

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

    About this skill

    Plans and writes expand/contract database migrations that never lock tables or break running code. Checks lock levels, backfills in batches, adds rollback steps. Postgres, MySQL, Prisma, Django, Rails, Alembic.

    How it works

    • Inspect first
    • Classify each operation
    • Write the plan as phased releases
    • Guardrails in every migration
    • Output

    Use it when

    You say add a column, rename a column, drop a table, change a type, add an index or NOT NULL on a big table, write a migration for production, or "will this migration lock the table".

    Why this one

    • Runs real checks instead of generic advice
    • Concrete output: files, tables and next steps you can act on today
    • Works with Claude Code, Codex CLI, Cursor, Gemini CLI and any SKILL.md agent

    More by Ignasi: Frontend Design Pro, Security Audit, Cut Agent Token Costs.

    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.

    Requires Postgres 11+ or MySQL 8.0+. Large backfills are generated as separate application scripts or jobs, not part of the primary migration transaction.

    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 today

    Permissions

    Read Files
    Write Files
    Listedtoday

    What's inside

    Frequently Asked Questions

    This skill automates the "expand-contract" pattern, which involves a multi-step release process (e.g., adding a new column while keeping the old one) to ensure the application remains functional while the database schema is in flux. It specifically generates code to avoid long-running locks that would otherwise freeze your production environment.

    The skill supports Postgres (11+) and MySQL (8.0+) and is compatible with most major ORMs including Prisma, Drizzle, TypeORM, Django, Rails (ActiveRecord), Alembic, Flyway, and Knex. It tailors the generated migration code to the specific syntax and safety features of your chosen framework.

    Unlike generic LLM prompts, this skill performs a deep analysis of your codebase to identify all read/write dependencies and enforces strict safety guardrails like lock timeouts and concurrent index creation. It is specifically programmed to handle the race conditions that occur between code deployments and database updates.

    The skill provides a comprehensive release plan divided into phases, the actual migration files for your specific ORM, and safety verification SQL to run against your database. For large-scale data changes, it also generates batched, idempotent backfill scripts that run outside of the main transaction.

    For massive tables, the skill avoids long-running transactions by providing resumable, batched backfill scripts designed to run as background jobs. This prevents the transaction log from bloating and ensures your "hot" tables remain readable and writable throughout the entire process.

    New in Data & Databases