All terms

Glossary

Expand and contract

Also: Parallel change

A procedure for database changes without downtime: expand first, switch second, remove the old thing last.

Renaming a column sounds harmless and is the classic cause of deployment outages, because old and new code run at the same time for a moment. Expand and contract solves this in three steps spread over several releases.

First the new column is added and written to as well. Then the reading side is switched. Only when no code needs the old column is it removed.

How you notice it

  • A schema change must not require downtime.
  • Old and new code will run side by side during a release.
  • A column needs renaming in a live system.

Frequently asked

How long do both versions coexist?

Until nothing reads the old shape any more, and that has to be measured, not assumed. Logging access to the deprecated field answers it in a week. Skipping the contract step leaves the schema permanently half migrated.

Read moreDual write and backfill: where migrations really tear