The Database Migration Rule of Three

Three discrete changes for every schema migration: add, dual-write, remove. The pattern that lets you ship migrations without downtime.

The three phases

Schema migrations break in production when add and remove happen in the same change. Splitting into three discrete phases keeps every state of the system serviceable.

Why this works

The three-phase pattern preserves rollback capability at every stage. The migration is reversible until the very last step.

Pitfalls

Three failure modes turn the rule into theatre. All three are upstream of the migration mechanics.