Rollback Planning
Purpose
Make recovery from a bad deploy fast and safe: know exactly how to get back to a good state, what can and can't be reversed, when to pull the trigger — and prove it works by rehearsing it before you need it.
When to Use
- When planning a deploy (rollback is part of the deploy design), and before production launches.
- Not for incident coordination broadly (
incident-readiness) — this is the deploy-reversal mechanism.
Inputs
- Deploy mechanism + artifact strategy (
../../backend/backend-deployment, docker-foundation).
- Migration flow (
../../database/database-migrations) and any feature-flag system.
Discovery Questions
- How fast can the previous artifact be redeployed (immutable, promotable versions make this minutes)?
- Which migrations are reversible, and which are roll-forward-only — and what does that mean for reverting code?
- Are risky changes behind feature flags that can be switched off without a redeploy?
- What triggers a rollback (smoke fail, error-rate spike, key flow broken), and who decides?
Responsibilities
- Code rollback: redeploy the previous immutable artifact quickly — the promote-across-environments model makes prior versions instantly available (
../../backend/backend-deployment); health-gate the rollback like any deploy.
- Migration reversibility rulings: know per migration whether it's reversible (honest down migration) or roll-forward-only (schema usually is — dropping data can't be undone). Design deploys expand/contract so code can roll back against a still-compatible schema (
../../database/database-migrations); where a schema change is one-way, the plan is fix-forward, stated in advance.
- Feature flags as fast rollback: gate risky features so they can be disabled instantly without a redeploy — the fastest "rollback" of all for behavior changes.
- Data safety on revert: writes made by the bad version may be incompatible with the old code — assess and plan (drain, migrate, or accept); backups/snapshots (
../../database/backup-recovery) as the last resort, not the primary plan.
- Triggers + ownership: explicit rollback triggers (post-deploy smoke fail, alert thresholds —
../../testing/smoke-testing, monitoring-logging) and who's authorized to call it.
- Rehearse: run the rollback in staging (
staging-environment) — an unrehearsed rollback is discovered broken mid-incident.
Required Workflow
- Confirm fast previous-artifact redeploy.
- Ruling per migration: reversible vs roll-forward-only; design expand/contract for compatibility.
- Identify feature-flag kill switches for risky changes.
- Assess data-safety on revert; define the backup fallback.
- Define triggers + decision owner.
- Rehearse in staging; record the runbook.
Decision Rules
- Code rolls back, schema usually rolls forward — design changes so old code survives the new schema during the window.
- Feature flags beat redeploys for reversing behavior — fastest and lowest-risk.
- A rollback that's never been run is not a rollback — rehearse it.
- Restoring from backup is the last resort (data loss between backup and now), never the first plan.
Rules
- Every significant deploy has a rollback plan before it ships.
- Migration reversibility is ruled explicitly, in advance.
- The rollback path is rehearsed, with triggers and an owner.
Anti-Patterns
- "We'll figure out rollback if it breaks."
- Destructive migrations deployed with no compatibility window, stranding code rollback.
- Backup-restore as the primary rollback (data loss, slow).
- No defined trigger — arguing about whether to roll back during the outage.
- Rollback path never tested until the real incident.
Validation Checklist
Definition of Done
A rehearsed rollback plan — fast artifact redeploy, explicit migration reversibility rulings with compatibility windows, feature-flag kill switches, data-safety assessment, and clear triggers with an owner — recorded and proven in staging before production deploys.
Related Skills
../../backend/backend-deployment, ../../database/database-migrations, ../../database/backup-recovery, ../../database/data-migration, staging-environment, ../../testing/smoke-testing, monitoring-logging, incident-readiness, production-readiness.
Related Knowledge
../../../knowledge/ (deploy mechanism, flag system, migration inventory).
Related References
../../../references/devops/ (rollback runbooks, when populated).
Context Loading Guidance
- Requires: deploy/artifact strategy, migration inventory, flag system.
- Does not require: broad incident process, app feature code.
- May load:
../../database/database-migrations, staging-environment.
- Stop when: the rehearsed rollback plan + triggers are recorded.
Token Efficiency Guidance
The rollback runbook (steps, migration rulings, triggers, owner) is the artifact; keep it executable and short.
1---2name: rollback-planning3description: Use to plan how to undo a bad deploy fast — previous-artifact redeploy, migration reversibility rulings (roll-forward vs down), feature-flag kill switches, data-safety on revert, clear triggers, and rehearsal. An untested rollback is a hope, not a plan.4---56# Rollback Planning78## Purpose910Make recovery from a bad deploy fast and safe: know exactly how to get back to a good state, what can and can't be reversed, when to pull the trigger — and prove it works by rehearsing it before you need it.1112## When to Use1314- When planning a deploy (rollback is part of the deploy design), and before production launches.15- **Not** for incident coordination broadly (`incident-readiness`) — this is the deploy-reversal mechanism.1617## Inputs1819- Deploy mechanism + artifact strategy (`../../backend/backend-deployment`, `docker-foundation`).20- Migration flow (`../../database/database-migrations`) and any feature-flag system.2122## Discovery Questions2324- How fast can the **previous artifact** be redeployed (immutable, promotable versions make this minutes)?25- Which migrations are **reversible**, and which are roll-forward-only — and what does that mean for reverting code?26- Are risky changes behind **feature flags** that can be switched off without a redeploy?27- What triggers a rollback (smoke fail, error-rate spike, key flow broken), and who decides?2829## Responsibilities3031- **Code rollback**: redeploy the previous immutable artifact quickly — the promote-across-environments model makes prior versions instantly available (`../../backend/backend-deployment`); health-gate the rollback like any deploy.32- **Migration reversibility rulings**: know per migration whether it's reversible (honest down migration) or roll-forward-only (schema usually is — dropping data can't be undone). Design deploys **expand/contract** so code can roll back against a still-compatible schema (`../../database/database-migrations`); where a schema change is one-way, the plan is fix-forward, stated in advance.33- **Feature flags as fast rollback**: gate risky features so they can be disabled instantly without a redeploy — the fastest "rollback" of all for behavior changes.34- **Data safety on revert**: writes made by the bad version may be incompatible with the old code — assess and plan (drain, migrate, or accept); backups/snapshots (`../../database/backup-recovery`) as the last resort, not the primary plan.35- **Triggers + ownership**: explicit rollback triggers (post-deploy smoke fail, alert thresholds — `../../testing/smoke-testing`, `monitoring-logging`) and who's authorized to call it.36- **Rehearse**: run the rollback in staging (`staging-environment`) — an unrehearsed rollback is discovered broken mid-incident.3738## Required Workflow39401. Confirm fast previous-artifact redeploy.412. Ruling per migration: reversible vs roll-forward-only; design expand/contract for compatibility.423. Identify feature-flag kill switches for risky changes.434. Assess data-safety on revert; define the backup fallback.445. Define triggers + decision owner.456. Rehearse in staging; record the runbook.4647## Decision Rules4849- Code rolls back, schema usually rolls forward — design changes so old code survives the new schema during the window.50- Feature flags beat redeploys for reversing behavior — fastest and lowest-risk.51- A rollback that's never been run is not a rollback — rehearse it.52- Restoring from backup is the last resort (data loss between backup and now), never the first plan.5354## Rules5556- Every significant deploy has a rollback plan before it ships.57- Migration reversibility is ruled explicitly, in advance.58- The rollback path is rehearsed, with triggers and an owner.5960## Anti-Patterns6162- "We'll figure out rollback if it breaks."63- Destructive migrations deployed with no compatibility window, stranding code rollback.64- Backup-restore as the primary rollback (data loss, slow).65- No defined trigger — arguing about whether to roll back during the outage.66- Rollback path never tested until the real incident.6768## Validation Checklist6970- [ ] Fast previous-artifact redeploy confirmed.71- [ ] Per-migration reversibility ruled; expand/contract for compatibility.72- [ ] Feature-flag kill switches identified for risky changes.73- [ ] Data-safety-on-revert assessed; backup fallback defined.74- [ ] Triggers + decision owner explicit.75- [ ] Rehearsed in staging; runbook recorded.7677## Definition of Done7879A rehearsed rollback plan — fast artifact redeploy, explicit migration reversibility rulings with compatibility windows, feature-flag kill switches, data-safety assessment, and clear triggers with an owner — recorded and proven in staging before production deploys.8081## Related Skills8283`../../backend/backend-deployment`, `../../database/database-migrations`, `../../database/backup-recovery`, `../../database/data-migration`, `staging-environment`, `../../testing/smoke-testing`, `monitoring-logging`, `incident-readiness`, `production-readiness`.8485## Related Knowledge8687`../../../knowledge/` (deploy mechanism, flag system, migration inventory).8889## Related References9091`../../../references/devops/` (rollback runbooks, when populated).9293## Context Loading Guidance9495- **Requires:** deploy/artifact strategy, migration inventory, flag system.96- **Does not require:** broad incident process, app feature code.97- **May load:** `../../database/database-migrations`, `staging-environment`.98- **Stop when:** the rehearsed rollback plan + triggers are recorded.99100## Token Efficiency Guidance101102The rollback runbook (steps, migration rulings, triggers, owner) is the artifact; keep it executable and short.