playframeworkslickplay-slick

Infinite loop of evolutions with Play! framework and play-slick


After updating my web project which uses Slick and the H2 in-memory database to Play 2.6, I get an infinite loop of these messages:

Database 'default' needs evolution! [An SQL script need to be run on your database.]

Clicking "Apply this script now!" runs the SQL and restarts the app - but the prompt is simply displayed again as if it had never been applied in the first place. How can I fix this?


Solution

  • As described in the official documentation, it is necessary to add ;DB_CLOSE_DELAY=-1 to the database connection URL, e.g.

    db.default.url = "jdbc:h2:mem:play;DB_CLOSE_DELAY=-1"

    Be sure to update slick.dbs.default.db.url too.

    This prevents the database from being lost as soon as the application restarts after the evolution is applied.