← ClaudeAtlas

probe-migration-in-transactionlisted

Use when a change adds or alters a SQL migration whose effect is a behaviour — an RLS policy, a view, a trigger, a grant, an enum, a constraint — and you want to know what it really does before opening the PR. Especially when there is no local Postgres: a transaction against the dev database that is rolled back costs nothing and leaves nothing. Do NOT fire for a bulk data write you intend to keep (that is reversible-bulk-write), for a migration that only adds a column nothing reads yet, or when the only database reachable is production.
damson/hard-won-skills · ★ 1 · API & Backend · score 67
Install: claude install-skill damson/hard-won-skills
# Probe a migration in a transaction The deliverable is a role × capability matrix for the PR body. ## Procedure 0. **Connect, then prove where you are.** Every `client` below is this one. The connection string comes from the project's dev environment — a `DEV_DATABASE_URL` in `.env`, the output of `supabase status`, the CI workflow — never from a guess: ```js const pg = require('pg'); const url = process.env.DEV_DATABASE_URL; if (!url) throw new Error('no dev connection string — stop'); // unset, pg const client = new pg.Client(url); // falls back to PG* env / localhost and await client.connect(); // connects *somewhere* without saying so ``` Before `begin`, ask the server what it is and compare against the dev target you meant to reach — the host and database named by the same source the URL came from: ```sql select current_database(), inet_server_addr(), inet_server_port(); ``` Match against what dev is *known* to be, not against a list of what production might be: anything that is not the expected dev identity — including an identity you cannot place — is the first STOP condition below, now mechanically checkable instead of known out-of-band. Refuse before `begin`, not after. 1. **Name the invariant and record it before touching anything.** One count on the table the migration must *not* reach — `widgets`, or whatever the change claims to leave alone. Step 6 re-reads it after the