Play!: Does Slick's DDL replace Evolutions?

假装没事ソ 提交于 2019-12-09 02:22:13

问题


This may be a dumb question but I'm new to Play! & Slick. While using Slick's table.ddl.create I noticed that it doesn't create an evolution but the application still works.

Does this replace evolutions? Can I use it in production? Should I?

Thanks in advance.


回答1:


Both Slick and the Slick DDL Plugin can only generate code to create or delete your schema, not to evolve it. So you still need Play evolutions or something similar to modify an existing schema along the way. In the Slick team, we are working towards a migration solution (on a lower priority). Many parts are already there, but haven't been integrated properly yet. There are @nafg's schema manipulation DSL: https://github.com/nafg/slick-migration-api and my one year old prototype for a database version management tool: https://github.com/cvogt/migrations/ . The code generation part of the latter has already made it into Slick 2.0. Properly integrating all of these will give us a comprehensive solution for type-safe database migration scripts.




回答2:


Slick is able to generate DDL for your defined tables it does not contain logic that does what evolutions does.

The play slick plugin on the other hand contains a SlickDDLPlugin that will generate and run DDL evolutions for you when you run your app in non prod-mode (with play run for example) It also dumps out those evolutions in your conf/evolutions directory.

The sources that handles evolutions: https://github.com/freekh/play-slick/blob/master/src/main/scala/play/api/db/slick/plugin/SlickPlugin.scala



来源:https://stackoverflow.com/questions/21404569/play-does-slicks-ddl-replace-evolutions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!