3 ms·
I believe the proper way to upgrade schema is to 1) don't change existing schema (don't alter columns) 2) introduce new schema, side by side (add new columns,
by adamzochowski 9y ago
I believe the proper way to upgrade schema is to
1) don't change existing schema (don't alter columns)
2) introduce new schema, side by side (add new columns, all nulls, without defaults)
3) update code to read new schema first, if nothing found, read old schema,
4) create triggers that a write in new or old schema updates the other
5) have a separate process to sequentially migrate data from old schema to new schema
6) once all records are migrated to new schema, start slowly removing code that reads old schema
7) once nothing reads old schema, delete it
Handling schema changes is a tricky process that is spread across multiple different steps, where each step can be rolled back.