How do you roll back safely when a deploy includes a database migration?
AdvancedProductionRelease Engineering and Progressive Delivery
Answer
Design so rollback never needs a schema rollback: backward-compatible migrations (expand/contract), deploy schema first, deploy code second, and drop old structures only in a later release. Down-migrations are used only in dev because they destroy data. For risky changes, take a snapshot or point-in-time marker before migrating, use online schema change tools for big tables (gh-ost, pt-online-schema-change, CREATE INDEX CONCURRENTLY in Postgres), and keep the feature behind a flag so you can disable behaviour without reverting.
More on Release Engineering and Progressive Delivery
How do you do zero-downtime deployments on Kubernetes?IntermediateHow do you implement a canary release with Argo Rollouts and automated analysis?AdvancedHow do you design an automated rollback trigger?AdvancedHow do you handle hotfixes in a trunk-based flow?IntermediateHow do you version and release libraries versus services?IntermediateWhat does a release train look like and when is it appropriate?Intermediate