If I have an existing table in a NoSQL database cluster and I want to add a new column that should never return null, how do I handle it in my application code?
- I can update all exist records and set that new column to some default value (if there is a sensible default).
- I can have my application code assume a default value if it reads a records with no value for the field
The problem I see with the first solution is that there may be existing code that writes records without the mandatory column leaving the table with "broken" records. The second solution may "mask" existing code that fails to write the new column value.
How do people handle this scenario?