Is there a way with Slick that you can run SQL code before the application starts or in the test set up like in Hibernate?
See example https://github.com/geowarin/hibernate-examples/tree/master/standalone-data-jpa/src/main/resources
Is there a way with Slick that you can run SQL code before the application starts or in the test set up like in Hibernate?
See example https://github.com/geowarin/hibernate-examples/tree/master/standalone-data-jpa/src/main/resources
You can use Evolutions
in Play framework. If you are using play-slick
, you can add play-slick-evolutions
dependency and make sure play.evolutions.enabled
is not set to false in application.conf
.
https://www.playframework.com/documentation/2.4.x/Evolutions
https://www.playframework.com/documentation/2.4.x/PlaySlick
[UPDATE]
As per your comment, it looks like you want your SQL to be run on startup rather than with migration. If such then you can use JavaGlobal/ScalaGlobal for Play < 2.4. Else you can take look into 2.4 GlobalSettings doc.
My question is kind of a duplicate question. See here Play Framework DML insert script.
With the play framework you only need to create a sql file in the evolutions directory called 2.sql with the insert statements that you need.
I'm still trying to figure out if you can do something like this without play in a stand alone sbt application.