What is best way to update Google datastore with new fields?
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 w开发者_运维百科ith newly added fields?
I need it for a java application on google app engine?
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.
精彩评论