Claude Code

Verified against Claude Code · 2026-07-21

Review a database migration for what it does to production before it runs there

A pre-execution review prompt that checks a migration script's locking behavior, backward compatibility during a rolling deploy, and reversibility against the actual table size and deploy strategy, instead of judging it purely on SQL syntax correctness.

Claude Code5 fillable variables

The prompt

Ready to copy — highlighted parts are example details you can swap.

Review this migration for what it will actually do to a live production database, not just whether the SQL is syntactically valid. A migration that is syntactically perfect and locks a hot table for eight minutes during business hours is still a bad migration.

MIGRATION SCRIPT
ALTER TABLE orders ADD COLUMN loyalty_tier VARCHAR(20) NOT NULL DEFAULT 'standard'; followed by a backfill UPDATE orders SET loyalty_tier = ... in the same transaction.

TABLE SIZE AND TRAFFIC CONTEXT
orders has 42 million rows and receives roughly 200 writes per minute during business hours, none at night.

DEPLOY STRATEGY
Rolling deploy across four instances, roughly 6 minutes for all instances to pick up new code, old and new code both serve traffic during that window.

DATABASE ENGINE
PostgreSQL 16

ROLLBACK PLAN IF THIS NEEDS TO BE UNDONE
A corresponding down-migration exists that drops the column; it has been tested against a pre-migration snapshot but not against a partially-completed backfill.

CHECK EACH OF THESE, IN ORDER
1. Locking behavior — for PostgreSQL 16 specifically, does this exact statement take a lock that blocks reads, blocks writes, or blocks both, and for how long is that lock plausibly held against a table of the size described above? A statement that is instant on a thousand-row table can hold a blocking lock for minutes on a hundred-million-row one, and the two cases require citing the actual mechanism, not a generic 'this should be fine.'
2. Backward compatibility during the deploy window — under Rolling deploy across four instances, roughly 6 minutes for all instances to pick up new code, old and new code both serve traffic during that window., old application code and new application code both run against the database simultaneously for some period. Does the schema after this migration still satisfy every query the old code will still issue during that window? A column drop or a rename that the new code expects but the old code does not know about is the single most common way a rolling deploy causes an outage that a migration reviewed in isolation would never catch.
3. Data loss risk — does this migration drop, truncate, or irreversibly transform any column or row, and if so, is there a real, tested way to get that data back if the migration turns out to be wrong, or is the loss permanent the moment it runs?
4. Reversibility — does A corresponding down-migration exists that drops the column; it has been tested against a pre-migration snapshot but not against a partially-completed backfill. actually work against the state the database will be in after this migration ran partway and then failed, not just after it ran to completion? A rollback plan tested only against the fully-succeeded case does not tell you what happens if this fails at row four million of a five-million-row backfill.
5. Index and constraint changes — does adding an index or constraint here lock the table for the duration of the build, and does this database engine support building it concurrently or online instead, if that option exists and was not used.

OUTPUT FORMAT
For each of the five checks: SAFE, RISKY, or BLOCKING, with the specific mechanism, not a generic caution. End with a recommended execution plan — run as-is, run with an explicit statement timeout and lock-wait retry, split into multiple smaller migrations, or do not run this until it is rewritten — and say plainly which of the five checks drove that recommendation.

Do not soften a BLOCKING finding into a RISKY one because the migration is otherwise well-written; the two ratings track different things, and this only tracks whether it is safe to run against this specific database in this specific state.

Customize

Optional — swap in your own details for the highlighted parts above.

Why this works

A migration script can be entirely correct SQL and still be the wrong thing to run against a specific production table, because syntax correctness and operational safety are answered by completely different questions — the first is about the statement in isolation, the second is about that exact statement against this exact table's size, this exact traffic pattern, and this exact deploy strategy, none of which the SQL itself encodes. Naming the database engine explicitly matters because lock behavior for what looks like the same operation genuinely differs by engine and version — an ADD COLUMN with a default value is a fast metadata-only change on a recent PostgreSQL version but was historically a full table rewrite on older releases and remains a full rewrite on some other engines, so a review that does not pin the engine is answering a question that has no single correct answer across the space of databases it could apply to. The backward-compatibility check during a rolling deploy window catches a failure mode that is invisible if the migration is reviewed as a standalone artifact: the actual danger period is not before or after the deploy, it is the middle, when old code that expects the previous schema and new code that expects the new schema are both live against the same database simultaneously, and a migration that looks completely fine at either endpoint can still break every request served by the stale instances during that overlap. Requiring the rollback plan to be checked against a partially-completed failure state, not just the fully-succeeded case, targets a specific optimism bias in how rollback plans get tested — a down-migration exercised only after a clean forward run tells you nothing about what happens if the forward migration fails at row four million of five, which is exactly the moment a real rollback plan is actually needed. Refusing to soften a BLOCKING finding because the migration is otherwise well-written matters because these two ratings are not on the same axis at all — a migration can be well-written and still be exactly the wrong thing to run against a hundred-million-row table during business hours, and a review that lets code quality bleed into a safety rating quietly launders a genuinely dangerous operation into something that reads as merely worth a second look.

Verified against

Claude Code Sonnet 4.6 · 2026-07-21

Changelog

  • 2026-07-21 — Initial publish, verified against Claude Code migration review (Sonnet 4.6).

Building this for real?

This is a free starting point. If you'd rather have custom software built and running for your business, that's Scult's day job.

EXPLORE CUSTOM SOFTWARE
All Claude Code prompts

Check your AI visibility

One URL in, a 0–100 score and the exact fixes out.

RUN THE CHECK

Browse all the tools

15 tools across six categories
13 of them never send your data anywhere

Free · No signup · No trial clock

SEE THE DIRECTORY