Skip to content
RED SAGSkills
mediumDevOps Engineer interview question

How do you include database schema migrations in a continuous delivery pipeline without causing downtime?

What the interviewer wants to hear

  • Migrations are versioned in the repo and run by a tool
  • Expand and contract: backward-compatible changes first
  • Old and new app versions must work with the schema during rollout
  • Run migrations as a separate controlled step before deploy
  • Test migrations on production-like data; watch locks on large tables
  • Rollback plan: roll app back, avoid destructive down migrations

Model answer

Migrations live in the repo as versioned files, applied by a tool such as Flyway, Liquibase or the framework migrator, and every environment records which ones ran. The main rule is that during a rolling deploy both the old and new app versions run at once, so every schema change must work with both. I use expand and contract: first add new columns or tables in a backward-compatible way, deploy code that writes to both or reads the new one, backfill in batches, and only drop the old structure in a later release. In the pipeline the migration runs as its own step, for example a Kubernetes Job or Argo CD PreSync hook, before the new pods start, and the deploy stops if it fails. I test migrations against a copy of production-sized data to catch long locks, and use online index creation. Rollback means rolling back the app, not running destructive down migrations.

Can you answer it under time pressure?

Take a timed medium round and get scored on every answer.

Start mock interview

More medium DevOps Engineer questions