Skip to main content

How do you handle database migrations in a CI/CD pipeline?

  • database migrations
  • zero-downtime
  • rollback

Answer it first, then compare. Nothing here is saved or scored.

Model answer

Steps: (1) Migrations versioned in code alongside application changes. (2) CI runs migrations against a test database before tests. (3) Validate rollback: every migration has an up and down path. (4) Zero-downtime migrations: use expand-and-contract pattern (add new column, deploy code that writes to both, migrate data, deploy code that reads from new, drop old). (5) Lock timeout protection: set statement_timeout to prevent long-running migrations from blocking production. (6) Test with production-scale data before deploying.

What interviewers listen for

  • Pipeline shape
    You design stages by failure cost and runtime budget, not by tool feature lists.
  • Parallelisation craft
    You can shard a real suite and explain the state-isolation choices you made.
  • Quality gates
    You know which checks block merge, which warn, and why those defaults are correct.
  • Shift-left fluency
    You talk about ownership transfer, not just earlier execution.

See all 34 ci/cd questions

Written by , Senior QA Automation Engineer, 50+ QA candidate interviews conductedLast updated July 2026