Reputation: 2388
I have to add new fields to existing tables. After I add the fields , the application breaks as old records do not have newly added field and throw exception. Is there a way to update all old records with newly added fields?
I need it for a java application on google app engine?
Upvotes: 3
Views: 504
Reputation: 8043
Though, I have not come across a strategy to update a model in the datastore, according to my expreiences. You have two options:
Update the existing rows in the datastore with default/null values for the newly added columns
Add a version based fetch function. For ex: Use a try catch block to fetch a newly added column, if it throws an exception, in the catch block, write a routine that will return version 1 of the datastore object. A migration object of sorts.
Upvotes: 1