Handle schema change in Google datastore with Go? -


i added new attribute go struct, persisted in datastore entity kind.

i tried load entities using filter on new attribute:

q := datastore.newquery("person").filter("employed =", false) 

this worked intended persons created after new attribute added.

i had expected persons created before attribute added incleded in filter, didnt have attribute @ all, excluded filter.

i have thought of 2 ways handle this:

  • first load entities , filter in second step loop. adds complexity code.
  • batch load , resave entities, adds property , sets false. have remember every time add new attribute.

is there batter way handle these types of entity schema changes?

the proper way re-save old entities if can afford it.

you can use python map/reduce library update old entities.

if want stick go can go simple batch processing using task queues & query cursors.

in our python app prefer "in-flight hot update" approach whenever possible - new version loads entities , check missing properties. if props obsolete keep them month or , add logic remove them. allows migrate gradually , rollback without issues (shit happens) or @ least limit impact small % of records. it's more cost effective not pay additional reads/writes. once sure ok can run mapreduce. not involve downtime. may need or don't need downtime - it's depend on change.

with go may bit tricky go panic if try load entity has no corresponding fields on struct. there should workarounds (i remember special interface or struct can load arbitrary entity) have no practical experience go on gae yet.


Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo