views:

45

answers:

2

I have a Model with a big blob property User.image Having this property in my model made my queries take too much time and go over the deadline so I decided to move that property into another model - UserData - who's parent is the User.

However, existing model instances that are already in the datastore still contain that image data even though the Model definition no longer contains that property.

Is there any, way to delete that data from the User instances?

A: 

I don't have the means to test this out right now, but I would try setting the image property to null or None (not sure if you're using Java or Python) while transitioning to use of the UserData class. You could just do this inline in your code as a way of deprecating the property, or you could set up a cron job that does this all at once. I'm not sure if there's a better way to completely remove the image property from the entity, but this would at least solve your problem of loading time.

Sean Devlin
+3  A: 

The answer to your question is documented here : http://code.google.com/intl/fr/appengine/articles/update_schema.html

Copy/paste from the "Removing Deleted Properties from the Datastore" section :

If you remove a property from your model, you will find that existing entities still have the property. It will still be shown in the admin console and will still be present in the datastore. To really clean out the old data, you need to cycle through your entities and remove the data from each one.

  1. Make sure you have removed the properties from the model definition.
  2. If your model class inherits from db.Model, temporarily switch it to inherit from db.Expando. (db.Model instances can't be modified dynamically, which is what we need to do in the next step.)
  3. Cycle through existing entities (like described above). For each entity, use delattr to delete the obsolete property and then save the entity.
  4. If your model originally inherited from db.Model, don't forget to change it back after updating all the data.
Franck