Works with the AI Agents you already use

    Postgres Migration Safety Linter (Supabase Ready)

    by Hayder Al-Hwaidi

    1

    Database migrations often cause production outages not through syntax errors, but through table locks and breaking changes.

    $5

    Secure checkout via Stripe

    Money-back guarantee

    Converts to your local currency at checkout

    Security scanned
    Postgres Migration Safety Linter (Supabase Ready)

    Postgres Migration Safety Linter (Supabase Ready)

    Example session with this skill installed

    Check this Supabase migration before I run db push on production. The orders table has about 2 million rows.

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

    Migration check: supabase/migrations/20261201_orders.sql

    Ran scripts/lint_migrations.py supabase/migrations --supabase:

    supabase/migrations/20261201_orders.sql
      [HIGH] line 1: index-not-concurrent
          CREATE INDEX without CONCURRENTLY blocks writes to the table until the index is built.
          fix: Use CREATE INDEX CONCURRENTLY in its own migration, outside a transaction block. New, empty tables are fine.
      [MEDIUM] line 1: missing-lock-timeout
          No lock_timeout: a migration waiting for a lock queues every other query behind it.
          fix: Start the migration with SET lock_timeout = '5s'; and retry on timeout.
      [HIGH] line 2: add-column-not-null-no-default
          ADD COLUMN ... NOT NULL without DEFAULT fails on any table that already has rows.
          fix: Add the column nullable, backfill in batches, then add NOT NULL (see set-not-null), or give a constant DEFAULT.
      [HIGH] line 3: rename
          RENAME breaks every running app version that uses the old name.
          fix: Expand/contract: add the new name (column or view), dual-write, migrate readers, remove the old name later.
      [HIGH] line 4: supabase-table-without-rls
          Table coupons in the public schema without ENABLE ROW LEVEL SECURITY in the same migration: readable and writable with the public anon key.
          fix: ALTER TABLE public.coupons ENABLE ROW LEVEL SECURITY; then add explicit policies.
    
    4 HIGH finding(s).
    

    Rewritten, zero-downtime version

    -- 20261201a_orders_index.sql (own file, no transaction)
    create index concurrently if not exists idx_orders_user on orders(user_id);
    
    -- 20261201b_orders.sql
    set lock_timeout = '5s';
    alter table orders add column status text;            -- nullable, instant
    alter table orders add column amount numeric;          -- new name, keep 'total' for now
    create table public.coupons (id bigint primary key, code text);
    alter table public.coupons enable row level security;
    

    Deploy order

    1. Run 20261201a, then 20261201b.
    2. Ship app code that writes both total and amount and sets status.
    3. Backfill status and amount in batches of 5,000 rows.
    4. Next release: add status NOT NULL via a NOT VALID check, switch reads to amount, then drop total.

    On a 2M-row table the original file would have blocked writes during the index build and failed outright on the NOT NULL column.

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

    About this skill

    Database migrations often cause production outages not through syntax errors, but through table locks and breaking changes. One unindexed foreign key or a blocking NOT NULL constraint on a large table can halt writes and crash your application. This skill identifies these risks in your SQL files and provides the exact zero-downtime rewrites required for safe deployment.

    What it does

    • Detects locking operations by flagging statements like CREATE INDEX (non-concurrent), ALTER TABLE additions, and type changes that trigger table rewrites.
    • Prevents data loss by identifying UPDATE or DELETE statements missing a WHERE clause.
    • Enforces Supabase security by checking for missing Row Level Security (RLS) on new tables and insecure SECURITY DEFINER functions.
    • Validates application compatibility by catching renames or dropped columns that break the currently running application code during a rolling deploy.
    • Provides safe rewrites for every finding, moving blocking operations to the expand-migrate-contract pattern.

    How it works

    1. Source migrations from your framework's directory, such as Supabase, Prisma, Drizzle, or Rails.
    2. Execute the linter on specific files or entire folders to generate a report of findings categorized by severity.
    3. Review safe patterns to replace high-risk SQL with non-blocking alternatives like NOT VALID constraints or concurrent index builds.
    4. Assess production impact by checking table sizes and row counts to determine if a finding is critical.
    5. Coordinate deployment by following the suggested deploy order to sync database changes with application releases.

    Frameworks & tools

    This skill works with Postgres migrations from Supabase, Prisma, Drizzle, Rails, Django, and Knex. It uses a Python-based linting script and standard SQL commands for database inspection.

    Why this beats prompting it yourself

    Generic AI prompts often miss the nuances of Postgres locking behavior or framework-specific transaction wrappers. This skill uses a structured approach focused on the expand-migrate-contract pattern and specific severity levels, ensuring you get production-ready SQL rather than just syntactically correct code.

    Use cases

    • Auditing a Supabase migration for RLS compliance and lock-free indexes.
    • Reviewing Prisma or Drizzle generated SQL for blocking ALTER TABLE calls.
    • Integrating a safety gate into CI pipelines that fails builds on high-risk SQL.
    • Planning a multi-stage migration to add a NOT NULL constraint to a million-row table.

    Known limitations

    The linter is offline and read-only, meaning it cannot verify actual table sizes without manual SQL execution. Operations on tables created within the same file are ignored.

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

    Software
    Python 3Postgres SQL migration files

    Permissions

    Terminal / Shell
    Read Files
    Listed4 days ago

    What's inside

    Frequently Asked Questions

    This skill audits Postgres migrations for locking operations like non-concurrent index creation or blocking NOT NULL constraints. It prevents production outages and data loss by identifying SQL that would halt writes or break compatibility with your currently running application code during a deployment.

    You should provide the skill with your SQL migration files or folders from frameworks like Supabase, Prisma, Drizzle, Rails, Django, or Knex. The skill uses a Python-based linting script and standard SQL commands to inspect your code without needing to connect to your live database.

    The linter provides a report of findings categorized by severity, along with specific zero-downtime rewrites for every risky statement it finds. You also receive a suggested deployment order to help synchronize your database changes with your application releases.

    The linter is an offline, read-only tool that cannot automatically verify actual table sizes or row counts. It also ignores operations performed on tables that were created within the same migration file, as new tables do not pose a locking risk.

    You can ask your agent to audit specific migration folders, such as your Supabase or Prisma directories, or request a check for a specific SQL file. You can also ask for the zero-downtime rewrite of a high-risk finding or request a deploy order for a multi-stage migration.

    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.