I'm using play 2.4 and Slick 3, Is it possible to generate automatically ddl scripts, it is evolutions?
In official docs I found some scripts, but where should I place it in play framework? http://slick.typesafe.com/doc/3.1.0/schemas.html
Do you know any libs to manage evolutions in code to not write plain SQL?
With Play 2.4 and newer, the slick plugin doesn't create evolutions any longer. For this I have added a page into development mode, that always shows the newest version of all evolutions in the browser. This approach is compatible with all coming changes in the module system, since it doesn't use any modules. An using dependency injection, it uses exactly that Slick database driver you have configured in your application.conf file
I have put the following line in config/routes:
Then I created a controller (app/controllers/SchemaEvolutionsController.scala)
For this controller there is of course a corresponding view (views/evolutions.scala.txt)
For the DAO objects I added a common trait to get the schema description (app/models/HasSchemaDescription):
Now for each DAO object, I must implement the trait and add the DAO to the SchemaEvolutionsController.
For example the DAO for serving cat objects:
With this example, you get the following result on http://localhost:9000/evolutions.sql
I made some workaround with PostgresDriver, I've created module, that prints DDL to file. After every code change I just need to replace 1.sql or later modify next evolution scripts:
ComputersDatabaseModule.scala
CreateDDL.scala
ComputersDAO.scala
Add in configuration (application.config):