Permalink
Browse files

Enable initOnMigrate with configuration key of db.${dbName}.migration…

….initOnMigrate
  • Loading branch information...
1 parent 34de80b commit 916d01455955eeb2f906d5ed0fecb2fad65cd24b @tototoshi committed Apr 28, 2013
Showing with 6 additions and 1 deletion.
  1. +6 −1 plugin/src/main/scala/com/github/tototoshi/play2/flyway/Plugin.scala
@@ -38,6 +38,9 @@ class Plugin(implicit app: Application) extends play.api.Plugin
private val playConfigDir = "conf"
+ private def initOnMigrate(dbName: String): Boolean =
+ app.configuration.getBoolean(s"db.${dbName}.migration.initOnMigrate").getOrElse(false)
+
private val flyways: Map[String, Flyway] = {
for {
(dbName, configuration) <- configReader.getDatabaseConfigurations
@@ -47,7 +50,9 @@ class Plugin(implicit app: Application) extends play.api.Plugin
val flyway = new Flyway
flyway.setDataSource(configuration.url, configuration.user, configuration.password)
flyway.setLocations(migrationFilesLocation)
- flyway.setInitOnMigrate(true)
+ if (initOnMigrate(dbName)) {
+ flyway.setInitOnMigrate(true)
+ }
dbName -> flyway
}
}

0 comments on commit 916d014

Please sign in to comment.