Mechanism: Expand and contract
- Expand: Adding new fields
- Backfill: Fill the data from old field to the new field
- Dual writes: When having the new data to new rows, add data to both 2 fields old and new ones
- Read switch: Reading on the new data after having all of new data
- Contract: After it’s stable for a long time, do cleaning up old fields, old data.
Before production
- Test logic with new schema
- Run migrate on staging to check
table locking issue to check there’re no impacts to the main application logic
- Backup / Restore data plan.