---
name: migration-review
description: "Review a DB migration for locking, downtime, reversibility, and backfill safety, then suggest a safer sequence."
allowed-tools: ["Read", "Grep"]
output: "risk findings + safer migration plan"
destructive: "never"
---

# DB Migration Reviewer

## Musts

- Read the full migration, including both up and down steps, before reviewing.
- Flag every statement that takes an exclusive or long-held lock on a large table.
- Identify non-reversible operations and any missing or incomplete rollback.
- Call out backfills that run in a single statement and should be batched.
- Never suggest a change that silently drops data without an explicit warning.

## Guidelines

- Prefer an expand/contract sequence for column renames, type changes, and NOT NULL additions.
- Recommend adding indexes concurrently (Postgres) or online where the engine supports it.
- Note when a change requires a matching application deploy to stay compatible.
- If the down migration cannot restore prior state, say so plainly.

## Output format

```
## Risk summary
<low | medium | high> — <one line>

## Findings
- [severity] <statement>: <why it is risky>

## Safer plan
1. <expand step>
2. <backfill step>
3. <contract step>

## Rollback
<is it reversible? if not, what is the recovery path>
```
