I am about to start a new project that will use the Play! 2 framework for Scala, probably using Squeryl as ORM (but maybe Slick would be fine too, if it ready in time).
Now, Play! has a feature to upgrade your database using migrations. Unforunately, these migrations are written in SQL. This is not only an inconvenience (I would like to be able to write migrations in Scala) but has two problems
So, I am looking for an alternative. I was not able to find any migration tool for any Scala ORM that would generate schema migrations automatically, is there any?
The best tool I could find is Scala migrations. Is there a way to make Play! automatically use it in place of its own migration tool?
Another alternative is Flyway, but it will not solve your integration issue.
For that, either you can implement a Plugin as it is done with standard Play! evolutions, either you could use the Global object to start the migration on the application start.
Evolutions in Play2 is implemented as a plugin. You could examine its implementation and roll your own along the same lines. As far as I can see, there isn't a simple way to just swap out the implementation for another.
One other tool that might be worth looking at is Liquibase. It is implemented in Java so should be easy to use from Scala.
I recommend liquibase. Liquibase is an open source, database-independent library for tracking, managing and applying database changes. It is built on a simple premise: All database changes are stored in a human readable yet trackable form and checked into source control. Liquibase can be used for both Java and Scala. The great thing about Liquibase is that you can use either XML, SQL, or combination of both for your db migration needs. It is easy to set up and use and has very extensive documents.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With