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.
More on CI/CD and production rollouts
Design a GitHub Actions workflow that builds, scans and pushes an image.IntermediateZero-downtime deploy on a single Docker host.AdvancedDeploy via GitOps with image digests.IntermediateCanary a new image on a Swarm service.AdvancedDocker build is flaky in CI due to network errors on package installs.IntermediateHow do you keep dev, CI and prod consistent?Beginner