A database migration must run once per deploy, before the app rolls out, with approval in prod. How do you model it?
AdvancedScenarioPipeline Design & Triggers
Answer
Situation read → Ordered, gated, and must not run concurrently.
What I'd do →
- Separate job
migratewithenvironment: prodandconcurrency: { group: migrate-prod, cancel-in-progress: false }. - Run the migration as a Kubernetes Job using the same image digest (
kubectl applythenkubectl wait --for=condition=complete job/migrate-<sha> --timeout=10m). deployhasneeds: migrate.- Migrations are backward compatible (expand and contract), so rollback of the app does not require rolling back the schema.
Why → Approval once, ordering guaranteed by needs, no parallel migrations thanks to concurrency.
Interview tip → Mention expand and contract; interviewers look for schema rollback awareness.
More on Pipeline Design & Triggers
You join a team whose single 900-line workflow runs everything on every push to every branch. How do you restructure it?IntermediatePushing to a PR branch runs CI twice (once for push, once for pull_request). How do you fix it?BeginnerProduct wants a "Deploy to staging" button that lets QA pick a version. Design it.BeginnerA nightly security scan should run at 02:00 India time on weekdays and also be runnable on demand. Write it.BeginnerYour team wants preview environments per PR on EKS, destroyed when the PR closes. Design the workflow.AdvancedTwo workflows must run in sequence: CI then a separate deploy workflow owned by another team. How do you link them?Intermediate