Testing purists and Cake Pattern fans will probably not like this answer, but we encountered the same problem as you have, and are doing the following:
We're using the default
database for running the app (on test on production systems), but for automated tests (using play test
) we use a separate test
db configuration, which has its own evolutions, and runs on H2 instead of PostgreSQL.
In Play, you can check if you're currently running test mode and can switch database accordingly:
lazy val default = Database.forDataSource {
val defaultSource = current.configuration.getString("db.test.url").fold("default")(_ => "test")
new play.api.db.DB.getDataSource(defaultSource)
}
Having separate evolutions for automated tests has other advantages too: you can populate the database with some basic test data which can be different from your other testing systems.
Hope that helps.