开发者

Altering Google AppEngine Datastore Table While Preserving Data

开发者 https://www.devze.com 2023-01-27 13:33 出处:网络
i am using python for developing Goog开发者_StackOverflow中文版le app engine application. my question is that while in development several times we need to modify the data models for adding, deleting

i am using python for developing Goog开发者_StackOverflow中文版le app engine application. my question is that while in development several times we need to modify the data models for adding, deleting or even changing the data type of some fields. But modifying models doesn't take effect until we use clear_datastore which destroys all data. is it true or i am doing some thing wrong ?


The datastore itself is schema-less; that means you can have entities of the same kind with different properties. So the changes do take effect, but existing data is not automatically updated to the new schema. Under the covers all entities are protocol buffers, something like a dict (key-value pairs).

When you want to make changes to your schema and have existing data that needs updated too, you'll need to convert it in some way. Often, you will need to write a special script to load the original entity, convert to the new schema, then re-put it. Google has an article discussing this topic.

0

精彩评论

暂无评论...
验证码 换一张
取 消