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
- How do you handle secrets in CI/CD pipelines securely?
- What are DORA metrics, and how would you use them without gaming them?
- 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.
- Your CI pipeline takes 45 minutes. How would you speed it up?
- What does 'build once, deploy many' mean, and why does it matter?
- What is platform engineering, and how does it relate to DevOps?
- How do you secure the CI/CD pipeline itself against supply-chain attacks?