开发者

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:

  1. Update the existing rows in the datastore with default/null values for the newly added columns

  2. 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜