Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

….initOnMigrate
  • Loading branch information...
commit 916d01455955eeb2f906d5ed0fecb2fad65cd24b 1 parent 34de80b
@tototoshi authored
View
7 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
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.