playframework-2.4play-slick

Run Evolutions in Command Line


It's my first day tinkering with the Play framework, and I'm having a hard time with evolutions. I'm using Play 2.4.

I picked a sample app from the many that come up in activator ui, it uses play-slick and play-slick-evolutions for DB connection and evolutions.

I've perused the docs, but I can't seem to find a way to run the evolutions from the command line. When I run activator on bash I get thrown into a shell, and the help doesn't bring up anything about running evolutions, or slick.

I've been doing PHP for a while, so I'm used to being able to run these up/down from the command line. I can drop the tables from the database client and do activator run which should prompt me to run the evolutions, but I'm looking for the right, manual way to do this. I imagine it's possible since it would need to be done on deploy.


Solution

  • As far as I know, they are not designed to be run manually. In development, Play asks you to run them: Play evolutions script application

    In Production I trigger the evolutions by starting my server with the parameter -DapplyEvolutions.default=true. You can write this (without -D of course) also to the application.conf-file to run them always. You can also use only the down- or up-evolutions with -DapplyUpEvolutions.default=true or -DapplyDownEvolutions.default=true.

    And of course there is always the option to just copy the part of the script you need manually and apply it with your favorite database tool. However, you then need to tell Play what you did by manually altering the table play_evolutions. An easier solution then would be to not use the evolutions mechanism provided by the Play Framework at all.