简体   繁体   中英

how to cleanly remove ndb properties

in my app i need to remove a few of my models properties.
i checked out this link but the first issue is that the properties are on a polymodel and there is no way im going to switch to an expando for the time to remove the properties, im not even shure what could happen if i change a polymodel to an expando .

so how do i remove properties from existing entities?

i was thinking to set all StringProperty to None and then remove these from the model schema and redeploy. one of those properties is a BooleanProperty , i can't set this one to None right?! or an ndb.PickleProperty ... how should i remove that?

does anybody know how to get this done properly?

If you want to update all your entities the recommended approach is a map/reduce job that reads and rewrites all entities; however it may not be worth it, depending on how much data you have -- the map/reduce isn't free either.

Also be sure you test the map/reduce job on a small subset of the data. It is remarkably subtle to truly remove a property from an entity, even if it's not in the model class any more! The best approach may be:

if 'propname' in ent._properties:
  del ent._properties['propname']
  ent.put()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM