Lesson 4.3

Zero-downtime migrations

A change that breaks the running application cannot be a single step.

7mIntermediate7.5k students

Overview

Expand, migrate, contract

A change that breaks the running application cannot be a single step. Add the new structure while the old one still works, migrate the data and the code, then remove the old structure once nothing reads it.

Renaming a column is the classic example: add the new one, write to both, backfill, switch reads, stop writing the old, drop it. Five deploys instead of one, and no downtime in any of them.

Build indexes concurrently so the table stays writable, and backfill in batches with pauses. A single update touching ten million rows holds locks and bloats the table.

In this lesson you will:

  • Split a breaking change into safe steps
  • Add indexes concurrently
  • Backfill in batches

Resources

Previous Lesson
Zero-downtime migrations — PostgreSQL for Application Developers — Vertex