Interview Prep/Docker/CI/CD and production rollouts

Run database migrations in the deploy flow of containerized apps.

IntermediateScenarioCI/CD and production rollouts
Answer

Situation read → Old and new code run concurrently during rollout.

What I'd do → Run migrations as a one-off job (docker compose run --rm migrate, a Kubernetes Job or init step) before switching traffic, using expand/contract: add columns first, deploy, then drop old ones later. Take a backup before destructive changes.

Why → Backward-compatible schemas enable rollback.

Interview tip → Never run migrations in every replica's entrypoint.

All Docker questions Roadmap: Docker & containers

More on CI/CD and production rollouts