# Ship or recover safely

Recipe · Bugs, speed and data · RDBR05

Verifies a risky database migration before deploy — or tests rebuilding/restoring your Postgres database on a separate copy — before anything touches production.

**Use it when:** You are about to ship a breaking schema change, or you have never tested recovering your database.

## Steps

1. Audit the pending migration or rebuild path: inspect rollout safety or source-rebuild completeness (read-only)
2. Check deploy overlap & half-finished failures: verify draining workers, locks, and interrupted transactions (read-only)
3. Rehearse on a separate database: run the migration or restore drill on an isolated copy with safe test data
4. Confirm recovery plan: verify tested results with zero unproved claims about production

## As one prompt

```text
Ship or recover safely. Verify a PostgreSQL migration or database rebuild on a separate copy before trusting it in production.

Run these steps one at a time. Wait for my yes after each step. Stay read-only on production at all times — every migration replay or restore test runs only on a separate database with safe test data, never on production.

Step 1 (audit change or rebuild — read-only): For a pending migration, review the diff against the live schema, active consumers, locks, old/new version coexistence, and rollback realism (reverting app code alone is not a schema rollback). For disaster recovery, audit whether the database can be rebuilt from repo migrations, source files, and backups, flagging anything that exists only in production. Bring back: concrete gaps and risks (file:line).

Step 2 (deploy window & partial failures — read-only, if needed): Trace what happens while old client bundles or background workers are still draining during deploy, and check transaction/timeout paths that could leave half-committed data. Bring back: any compatibility break or half-committed failure path (file:line).

Step 3 (isolated rehearsal): On a separate test database only, execute the migration (and rollback plan) or full rebuild/restore, and compare sampled rows and queries before and after.

Step 4 (go/no-go summary): Report what the isolated test proved, any remaining risks or manual steps, and whether it is safe to proceed.

Start your report in plain English: what you found, what it means, and whether I need to do anything. Put files, lines and commands underneath.
```

Source: https://www.atlasscope.dev/prompts/ship-or-recover-safely-rdbr05
