Agent-Written Down Migrations or Human Recovery Runbooks: A Rehearsal-First Debate
说明与用途
团队可以可靠地回滚增量迁移,同时确保破坏性更改具有记录的恢复路径,从而降低事故风险并改进 PR 质量。
问题
Teams often author only up migrations, leaving down migrations or recovery runbooks missing, causing rollback failures when destructive changes occur.
结果
Teams can reliably rollback additive migrations while ensuring destructive changes have documented recovery paths, reducing incident risk and improving PR quality.
工作流
- 1. Classify migration change class (additive, backfill, index, drop, constraint).
- 2. Apply decision rule: if DDL can restore state, allow agent to author down migration; otherwise, require human runbook.
- 3. Add rule to pull request checklist.
- 4. Run CI rehearsal script (rehearsal.sh) against disposable DB to verify up/down schema equivalence and that up changes something.
- 5. If rehearsal passes, merge; if not, fail PR and address issues.
- 6. For destructive changes, create and document a human-authored recovery runbook.
- 7. Store runbook in repository and reference in PR.
- 8. Periodically review runbooks for long-lived branches.
证据
Author the down migration with an agent only when DDL alone can restore the previous state; anything that destroys values needs a human-authored recovery runbook.
The script below rehearses an up/down pair and fails when the down-path is not schema-equivalent, or when the up-path changed nothing.
- 记录日期: 2026-09-20T03:15:21.172Z