Google App Engine、BigTable 和模型演变
我目前正在使用 Spring/JPA/Google App Engine,有一个问题令我担心。
GAE 的一个很酷的事情是,一旦定义了映射,我只需要插入数据,与之相关的所有内容也会被存储。
但是,如果我碰巧更改了映射,我该如何处理以前的数据呢?每次发生更改时我都必须创建迁移脚本吗?在这种情况下有没有办法使用 Liquibase 或类似的东西?或者是否有另一种方法来处理现有数据的这些更改?
非常感谢您的帮助! 罗尔夫
I am currently playing with Spring/JPA/Google App Engine, and there is an issue that I am worrying about.
The cool thing with GAE is, once my mapping is defined, I just need to insert data and everything associated to it is stored too.
However, if I happen to change my mapping, how can I do with my previous data ? Do I have to create migration scripts each time something has changed ? Is there a way to use Liquibase or something like that in this case ? Or is there another way to handle these changes on existing data ?
Thanks a lot for your help!
Rolf
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这取决于这些更改的性质,但在大多数情况下,至少需要进行一些轻微的更新。要记住的一件大事是父子关系(请参阅 上一个问题了解更多详细信息)和设计时的实体组;由于父母成为实体键的一部分,因此它们非常不可变。与键名相同。
另一件事是应用程序引擎实体是无模式的;例如,如果您有某个类
Foo
,并且突然向其添加属性prop = db.BooleanProperty(default=True)
,则所有现有的Foo
code> 实体不会将prop
设置为 True(尽管新实体会设置为 True)。同样,您必须手动管理ReferenceProperty
和ListProperty(db.Key)
。 App Engine 确实有一个_set
运算符来帮助解决此问题,但说实话,我发现它有点不可靠,当我知道时_set
会显示为空事实上,他们不应该这样。无论如何,这里有关于使用_set
功能。It depends on the nature of those changes, but in most cases, at least some light updating will be required. One big thing to keep in mind is parent-child relationships (see this previous question for more details) and entity groups while design; since parents become part of an entity key, they are very much immutable. Same with key names.
Another thing is that app engine entities are schemaless; for example if you have some class
Foo
and you suddenly add a property,prop = db.BooleanProperty(default=True)
to it, all existingFoo
entities will not haveprop
set to True (though new ones will). Likewise, you will have to manageReferenceProperty
s andListProperty(db.Key)
manually. App Engine does have a_set
operator to help with this, but to be honest I've found it to be a bit unreliable, with_set
s coming out empty when I knew for a fact that they should not be. Regardless, here's the documentation on using the_set
functionality.