- Home
- Skills
- Data & Databases
- Postgres Migration Safety Linter (Supabase Ready)
Works with the AI Agents you already use
Postgres Migration Safety Linter (Supabase Ready)
Database migrations often cause production outages not through syntax errors, but through table locks and breaking changes.
$5
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
- Run 20261201a, then 20261201b.
- Ship app code that writes both
totalandamountand setsstatus. - Backfill
statusandamountin batches of 5,000 rows. - Next release: add
statusNOT NULL via a NOT VALID check, switch reads toamount, then droptotal.
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 TABLEadditions, and type changes that trigger table rewrites. - Prevents data loss by identifying
UPDATEorDELETEstatements missing aWHEREclause. - Enforces Supabase security by checking for missing Row Level Security (RLS) on new tables and insecure
SECURITY DEFINERfunctions. - 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
- Source migrations from your framework's directory, such as Supabase, Prisma, Drizzle, or Rails.
- Execute the linter on specific files or entire folders to generate a report of findings categorized by severity.
- Review safe patterns to replace high-risk SQL with non-blocking alternatives like
NOT VALIDconstraints or concurrent index builds. - Assess production impact by checking table sizes and row counts to determine if a finding is critical.
- 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 TABLEcalls. - Integrating a safety gate into CI pipelines that fails builds on high-risk SQL.
- Planning a multi-stage migration to add a
NOT NULLconstraint 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
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
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 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
What's inside
Frequently Asked Questions
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.