Playframework Scala Evolutions更改数据库名称以进行测试

时间:2016-02-10 17:18:48

标签: scala playframework-2.4 playframework-evolutions

我在此文件中有我的数据库结构

myproject/conf/evolutions/mydatabasename/1.sql

我有测试配置

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"
  )
)

如果我更改文件夹名称' mydatabasename'对于'默认'并在配置文件' mydatabasename'对于'默认'它有效,但是当我尝试更改名称时,却没有。有没有办法使这项工作?

谢谢

1 个答案:

答案 0 :(得分:0)

首先,确保在evolutions库依赖项中启用了build.sbt模块,否则与进化相关的所有内容都将无声地失败。

您的配置似乎已经过时了2.4.x,您需要像这样更改它,特别是为您的数据源启用演进:

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"
)

请参阅文档中的Evolutions Configuration