DevOps Engineer interview question · Most asked
How do you handle database schema migrations in an automated deployment pipeline?
Summary
Make every migration backward compatible with the code that is running (expand and contract), run migrations as a separate, controlled pipeline step before the new code rolls out (not on application start-up across many replicas), make them idempotent and reviewable, and keep destructive changes for a later release after nothing uses the old schema.
Longer Answer
Example of renaming a column: add the new column, deploy code that writes both and reads the old, backfill in batches, switch reads to the new column, stop writing the old, then drop it in a later release. Large table changes need online schema tools or batching to avoid locks. Rollbacks then mean deploying previous code, which still works with the expanded schema; never rely on "down" migrations in production for destructive changes.
Key Points
- Expand and contract.
- Separate migration step, run once.
- Backward compatible with running code.
- Destructive changes later; batch big changes.
More most-asked DevOps Engineer questions
- A rollback after a release made the outage worse because the database had already been migrated. How do you design releases so rollbacks are always safe?
- Every deployment produces a burst of 502s. What do you check?
- What happens when you type a URL into a browser and press Enter?
- Design a CI/CD pipeline for a containerised microservice from commit to production.
- Pods keep restarting with OOMKilled under load. How do you investigate and fix it?
- What are DORA metrics, and how would you use them without gaming them?
- How do you handle secrets in CI/CD pipelines securely?
- Your CI pipeline takes 45 minutes. How would you speed it up?