Playframework Scala Evolutions change database name for test

505 views Asked by At

I have my database structure in this file

myproject/conf/evolutions/mydatabasename/1.sql

and I have this configuration for tests

implicit override def newAppForTest(td: TestData): FakeApplication = FakeApplication(
  additionalConfiguration = Map(
    "evolutionplugin" -> "enabled",
    "db.mydatabasename.driver" -> "org.h2.Driver",
    "db.mydatabasename.url" -> "jdbc:h2:mem:play;MODE=MYSQL",
    "db.mydatabasename.logStatements" -> true,
    "db.mydatabasename.username" -> "root",
    "db.mydatabasename.password" -> "root",
    "logback.com.jolbox" ->  "ERROR"
  )
)

If I change the folder name 'mydatabasename' for 'default' and in the configuration file 'mydatabasename' for 'default' it works, but when I try to change the name, it does not. Is there a way to make this work?

Thank you

1

There are 1 answers

1
Mikesname On

First, make sure that you have the evolutions module enabled in your build.sbt library dependencies, otherwise everything evolution-related will silently fail.

Your configuration appears to be outdated for 2.4.x, and you need to change it like so, specifically enabling evolutions for your data source:

additionalConfiguration = Map(
  "play.evolutions.db.mydatabasename.enabled" -> true,
  "db.mydatabasename.driver" -> "org.h2.Driver",
  "db.mydatabasename.url" -> "jdbc:h2:mem:play;MODE=MYSQL",
  "db.mydatabasename.logStatements" -> true,
  "logback.com.jolbox" ->  "ERROR"
)

See Evolutions Configuration in the docs.