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

Medium Topic: CI/CD May 24, 2026

Database migrations are one of the riskiest parts of deployment. The golden rule: migrations must be backward-compatible because during a rolling deploy, old code and new code run simultaneously.

Safe migration checklist:

  1. Never: Rename or drop a column in the same deploy that uses the new name.
  2. Step 1: Add new column (nullable, backward-compatible).
  3. Step 2: Deploy code that writes to both old and new columns.
  4. Step 3: Migrate existing data.
  5. Step 4: Deploy code using only the new column.
  6. Step 5: Drop the old column.
← Previous What is the purpose of a staging environment...

Practice Similar Questions

Back to CI/CD Topics