Google app engine database

Kev Dwyer kevin.p.dwyer at gmail.com
Sun Feb 23 10:56:55 CET 2014


glenn.a.isaac at gmail.com wrote:

> Is there a way to make sure that whenever you're making google engine app
> iterations to a database that that info does not get wiped/deleted. 
> Please advise

It's not clear what you mean here; I'll guess that by "iterations" you mean
"changes" by "database" you mean the db or ndb datastore and by "info" you 
mean "data stored in the datastore".  Apologies if this isn't so.

Appengine doesn't document any migration utilities to handle changes in your 
datastore schema, so you need to manage the effects of such changes 
yourself.

To ensure that you do not lose data when changing your model code, avoid 
making destructive changes to your models, i.e.

 - don't delete properties from a model
 - don't rename properties on a model 

If you must make these changes for some reason, you'll need to migrate the 
data somehow.

In my experience with Appengine, data is not actaully lost if you make 
destructive changes to your models, it becomes inaccessible becuae the 
property names it was stored under no longer exist on the model.  In theory 
you could access the data by adding the proprties back to the model or 
(maybe) by loading a different model definition in the remote shell, but 
this is not something that you would want to rely on in a production 
environment.

tl,dr: it's ok to add new properties to you models, but don't remove or 
rename properties.

Hope that helps,

Kev




More information about the Python-list mailing list