Interview Prep/CI/CD/Release Engineering and Progressive Delivery

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.

All CI/CD questions Roadmap: CI/CD fundamentals

More on Release Engineering and Progressive Delivery