views:

51

answers:

1

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?

+1  A: 

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.

Ritesh M Nayak
i think i have to live with try catch, unless someone comes up with better strategy. I was hoping to avoid it as code is spread in multiple places. Anyways thanx for your exhaustive response.
dhaval