Backward compatible database changes
May 9, 2023Taylor Barnett

Summary
This post details the 'expand, migrate, contract' pattern for safely making backward-compatible database schema changes, which is crucial for avoiding downtime and disruptions. It breaks down the pattern into six steps: expanding the schema, expanding application code to write to both old and new schemas, migrating data, migrating application code to read from the new schema, contracting application writes to only the new schema, and finally contracting the schema by deleting the old elements. The post also provides an example walkthrough of this pattern for combining a `star` table into a `repo` table by adding a `star_count` column.