Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Play migrations alternatives [closed]

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

  • first, I need to write migrations on my own. I am used to South, that is able to infer schema migrations by looking at the current and previous definitions of my models;
  • second, it would be very cumbersome to handle data migrations. One may have the need to alter data programmatically, and this may not even be doable in plain SQL.

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?

like image 711
Andrea Avatar asked Aug 17 '12 09:08

Andrea


3 Answers

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.

like image 66
ndeverge Avatar answered Nov 18 '22 23:11

ndeverge


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.

like image 24
Brian Smith Avatar answered Nov 19 '22 00:11

Brian Smith


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.

like image 5
Eun Woo Song Avatar answered Nov 19 '22 01:11

Eun Woo Song