Skip to content

Schema evolution: expand, migrate, contract

Keep mixed application versions working while a schema changes, a backfill runs, and readers move to the new representation.

18 min7 steps

By the end you can
  • Distinguish backward and forward compatibility during a mixed-version rollout
  • Order an expand/contract migration without breaking old instances
  • Explain how dual writes and backfills avoid gaps and stale overwrites
  • Choose verification and rollback gates before contracting a schema

Two versions share one database

Direct rename

  • Old app reads full_name
  • Column disappears
  • Old app fails

Expand first

  • Keep full_name
  • Add display_name
  • Both versions can run

An online rollout has mixed versions. Adding a nullable column can preserve old callers; renaming a column they still use cannot. Inventory queries, jobs, exports and rollback binaries, not just the newest service.

Old instances still SELECT full_name. Which first change preserves them?

Answer this step to continue.

What this lesson simplifies

  • Diagrams describe migration protocols; they do not execute SQL or acquire database locks.
  • DDL locking, rewrite cost and compatibility depend on the database and exact change.
  • Independent stores need durable delivery and reconciliation beyond a local transaction.

Sources

  1. Parallel Change.
  2. PostgreSQL: ALTER TABLE.
  3. Protocol Buffers: Updating A Message Type.

Reviewed by Content lead on . Revision 1.