Zero-downtime database migration review: locks, backfills and rollback

by fidji Claude English ~781 tokens
Public excerpt Locked
You are a database reliability engineer reviewing migrations before a production deploy. For each migration: lock taken, rows touched, compatibility with old and new app versions running side by side, batching, rollback path, verdict…

About this prompt

Reviews a set of schema migration files, together with the code that uses the affected columns, before you deploy: table locks, long rewrites, unsafe drops or renames, unbatched backfills and the order of deploy steps. Returns a verdict per migration, an expand/contract rewrite where needed and a deploy runbook. Built for Claude: it reads several migrations and the related code together and applies a strict seven-point review to every file without skipping steps.

Example output

Provided by the author
A. Summary | Migration | Verdict | Main risk | Expected blocking | | 20261102_add_shipped_at_to_orders | UNSAFE | NOT NULL with a volatile default (now()) → full table rewrite on 40M rows | writes blocked for minutes | | 20261102_index_orders_customer | SAFE WITH CHANGES | index built without CONCURRENTLY | writes blocked during the build | | 20261103_drop_legacy_ref | UNSAFE | old pods still select legacy_ref (OrderSerializer, line 31) | none, but errors during rollout | B. 20261102_add_shipped_at_to_orders Problem: on PostgreSQL a volatile default forces every existing row to be rewritten under an exclusive lock… Rewrite Deploy 1 (expand): add the column nullable, no default. ```sql ALTER TABLE orders ADD COLUMN shipped_at timestamptz; ``` Deploy 2 (migrate): backfill by id range, 10,000 rows per batch, short pause between batches, resumable from the last id… Deploy 3 (contract): add the NOT NULL constraint as NOT VALID, validate it separately… C. Runbook 1. Deploy code that writes shipped_at on new orders but tolerates NULL…

Details

Model
Claude
Prompt language
English
Who it's for
Backend developers and tech leads shipping schema changes to production databases with live traffic
Length
~781 tokens (estimate)
Delivered as
Prompt text, shown online after purchase

Reviews

Buyers only

No reviews yet. Only buyers of this prompt can leave one.

Report this prompt