More screenshots

    Works with the AI Agents you already use

    Moonlight Safe Db Migration

    by LINGALA SURESH

    2

    Generate and review zero-downtime database migrations with automated lock analysis and multi-phase deploy plans.

    Free

    Security scanned
    Moonlight Safe Db Migration

    Moonlight Safe Db Migration

    Example session with this skill installed

    /safe-db-migration rename users.fullname to users.display_name without downtime for a PostgreSQL Rails app

    • Read your context and instructions
    • Compiled the moonlight safe db

    I have analyzed the request to rename users.fullname to users.display_name. To ensure zero-downtime, I have decomposed this into a multi-phase plan to maintain compatibility during the rolling deploy.

    Zero-Downtime Migration Plan

    PhaseActionPurpose
    1. ExpandAdd display_name column (nullable)Allow new app version to write to new column.
    2. BackfillBatch copy fullname to display_namePopulate new column with existing data without locking table.
    3. SwitchUpdate app to read/write display_nameMove application logic to the new schema.
    4. ContractDrop fullname columnCleanup phase (requires separate approval).

    Migration: 20231027100000_add_display_name_to_users.rb

    class AddDisplayNameToUsers < ActiveRecord::Migration[7.0]
      def change
        # Add column as nullable first to ensure compatibility
        add_column :users, :display_name, :string
        
        # Add index concurrently to avoid locking
        commit_db_transaction
        add_index :users, :display_name, algorithm: :concurrently
      end
    end
    

    Risk Analysis

    • Statement: add_column
    • Lock Level: Access Exclusive (short)
    • Risk: Low. PostgreSQL adds nullable columns without a table rewrite.
    • Statement: add_index
    • Lock Level: Share Update Exclusive
    • Risk: Minimal. Using algorithm: :concurrently prevents blocking reads/writes.

    Verification Query

    SELECT count(*) FROM users WHERE display_name IS NULL AND fullname IS NOT NULL;
    

    Next steps

    1. Review the generated migration and run rails db:migrate locally.
    2. Execute the provided backfill script in a background worker.
    3. Deploy the application update that dual-writes to both columns.

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

    About this skill

    Database schema changes are high-risk operations that often cause downtime through long-held locks or application-level incompatibilities. This skill automates the creation and review of migrations to ensure zero-downtime deploys. It identifies risky DDL statements, manages deployment ordering, and structures changes into safe release phases.

    What it does

    • Multi-phase planning decomposes destructive changes into expand, backfill, switch, and contract release cycles.
    • Risk analysis identifies statements causing table rewrites, exclusive locks, or duration-based failures.
    • Migration generation writes idempotent code for tools like Prisma, Alembic, Rails, or TypeORM with appropriate timeouts.
    • Verification queries generates SQL to validate data integrity and backfill progress before proceeding.
    • Safety reviews audits existing PRs for missing rollbacks, deployment ordering issues, and data loss risks.

    How it works

    1. Discovery scans your repository to identify migration tooling, existing schema, and deployment topology.
    2. Analysis evaluates the requested change against a risky-operation table to determine locking impact.
    3. Execution generates the necessary migration files and application code adjustments for dual-writing or reading.
    4. Validation runs the migration against a local disposable database to report timing and rollback success.

    Frameworks & tools

    Supports Prisma, TypeORM, Sequelize, Knex, Flyway, Liquibase, Alembic, Rails, and golang-migrate. Works with PostgreSQL, MySQL, and other relational engines.

    Why this beats prompting it yourself

    Generic prompts often miss the nuances of rolling deploys where old and new app versions coexist. This skill enforces strict DDL timeouts and concurrent index creation that basic LLM outputs typically omit, preventing production outages.

    Use cases

    • Adding a non-nullable column to a high-traffic table without blocking writes.
    • Renaming a column by implementing a dual-write and backfill strategy.
    • Adding a unique index concurrently to avoid long-lived access exclusive locks.
    • Reviewing a junior developer's migration PR for potential lock contention.

    Known limitations

    Does not support NoSQL databases. Will not execute migrations on shared, staging, or production environments. Destructive actions require explicit human approval.

    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

    Free to use

    No account required to browse

    Frequently Asked Questions

    This skill specializes in zero-downtime strategies, automatically splitting risky DDL into multi-phase steps (expand, backfill, contract) and enforcing safety measures like concurrent indexing that standard LLMs often overlook.

    It supports a wide range of popular ORMs and migration tools including Prisma, TypeORM, Alembic, Rails, and Liquibase, working across PostgreSQL, MySQL, and other relational engines.

    No, for security and safety, the skill only generates code and validates it against local disposable databases; it will never directly execute changes on your staging or production environments.

    The skill scans your repository to identify your existing schema and migration history, then provides a structured plan and the necessary idempotent code files to implement the change safely.

    You receive the full logic for multi-phase planning, risk analysis modules for locking statements, and a suite of verification query generators tailored to your specific tech stack.

    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.

    Free