Introducing a Database Column for Existing Rows
A schema change must account for data created before the new column existed and for writes occurring during rollout.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 4
- Reading time
- 1 min
In this article4 chapters
Trace a new unit field
A duration previously stored only as milliseconds can add an explicit unit field. Existing rows need a valid default or a careful backfill. Column defaults govern later writes separately.
Verify compatibility deliberately
Read records saved before and after the change using the intended application versions. Serialized record versioning illustrates the same concern across file formats.[1][2]
Define a default without rewriting history by assumption
A new mandatory duration field cannot be filled accurately from old rows if the duration was never recorded. A schema change can first allow absence, backfill records with evidence, then require the field where a complete rule can hold. See SQL default values.
Add field with temporary absence allowed
Current writer supplies real values
Backfill only where source information supports it
Enforce the final shape once existing records qualify
Test old and new write paths during deployment
Staged releases can run mixed code versions. Try an older row without the field and a new row with it. Check counts and sample values across every meaningful category.