简体   繁体   English

如何扩展Play2的发展

[英]How to scale Play2 Evolutions

I'm recently started using Play2 on a project, and read the section on evolutions . 最近,我开始在一个项目上使用Play2,并阅读有关Evolution的部分。 And while the example they cite seems fine if my project had 1 table, it seems like it would be very messy if I had 10-20 tables in 1.sql and then changes to them split up over 2.sql , 3.sql and so on. 虽然他们引用的示例在我的项目中只有1个表的情况下看起来很好,但是如果我在1.sql有10-20个表,然后将其拆分为2.sql3.sql和以此类推。

In Ruby on Rails, Symfony, and others, you define your up/down migrations per entity. 在Ruby on Rails,Symfony等中,您可以定义每个实体的上/下迁移。

My question is, what is the best way to setup your evolutions in Play2? 我的问题是,在Play2中设置进化的最佳方法是什么? Should I have all my tables in 1.sql and then make little changes to them over 2.sql and so on? 我是否应该将所有表都放在1.sql ,然后通过2.sql等对其进行一点更改? Or is there a way to have a separate .sql file for each table? 还是有一种方法可以为每个表使用单独的.sql文件?

Also, are there any examples of large, open source Play2 projects where I could see how it would look? 此外,是否有大型开放源Play2项目的示例,让我可以看到它的外观?

Actually Play has not possibility to divide evolutions by entities. 实际上,游戏不可能将进化划分为实体。

IMHO it's rather matter of taste, you can add each entity in single next evolution, anyway only difference will be that counter of evolution will be bigger, I don't think that will help you to keep evolutions cleaner. 恕我直言,这很有趣,您可以在单个下一个演化中添加每个实体,无论如何区别只是演化的计数器会更大,我认为这不会帮助您保持演化的整洁。

Typical workflow is starting from ... good planning. 典型的工作流程始于……良好的计划。 Just create some graph representation of your schema and try to add there as many things as you need. 只需为您的模式创建一些图形表示,然后尝试在其中添加所需数量的内容即可。 It helps a lot while the project startup and also in next steps of development. 在项目启动以及开发的后续步骤中,这将有很大帮助。

If you are gonna to use Ebean, create all models from your graph and let the plugin to create automatic first evolution file, probably you will save a lot of time on writing evolutions for relations, constraints, etc. Spend some time for fixing and checking initial schema before further development. 如果要使用Ebean,请从图形中创建所有模型,并让插件创建自动的第一个演化文件,可能会节省大量时间来编写关系,约束等的演化。花一些时间进行修复和检查在进一步开发之前的初始架构。

After that you need to disable automatic updates as they drops whole DB and recreates tables them from the scratch (there's no diff schema update in Ebean). 之后,您需要禁用自动更新,因为它们会删除整个数据库并从头开始重新创建表(Ebean中没有diff模式更新)。

It's also matter of taste but I prefer to combine several changes into single evolutions (so again planning...) instead of creating next and next files for every single change ad hoc. 这也很有趣,但是我更喜欢将多个更改组合到单个演变中(因此再次计划...),而不是为每个单个更改临时创建下一个和下一个文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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