在保留数据的同时更改 Google AppEngine 数据存储表

发布于 2024-10-05 07:11:18 字数 141 浏览 1 评论 0原文

我正在使用 python 开发 Google 应用程序引擎应用程序。我的问题是,在开发过程中,我们多次需要修改数据模型,以添加、删除甚至更改某些字段的数据类型。但是,直到我们使用clear_datastore销毁所有数据后,修改模型才会生效。这是真的还是我做错了什么?

i am using python for developing Google 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 ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小…红帽 2024-10-12 07:11:18

数据存储区本身是无架构的;这意味着您可以拥有具有不同属性的同类实体。因此,更改确实生效,但现有数据不会自动更新到新架构。 在幕后所有实体都是协议缓冲区,类似于字典(键值对)。

当您想要更改架构并且现有数据也需要更新时,您需要以某种方式对其进行转换。通常,您需要编写一个特殊的脚本来加载原始实体,转换为新模式,然后重新放置它。 Google 有一篇讨论此主题的文章

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文