Flyway
Enables you to configure and run Flyway commands from your mill build file. The flyway module currently supports the most common flyway use cases with file based migrations.
Configure flyway by overriding settings in your module. For example
build.mill//| mvnDeps: ["com.lihaoyi::mill-contrib-flyway:$MILL_VERSION"]
package build
import mill.*, scalalib.*
import contrib.flyway.FlywayModule
object foo extends ScalaModule with FlywayModule {
def scalaVersion = "2.12.8"
//region flyway
def flywayUrl = "jdbc:postgresql:myDb" // required
def flywayDriverDeps = Seq(mvn"org.postgresql:postgresql:42.2.5") // JDBC driver
def flywayPluginDeps = Seq(mvn"org.flywaydb:flyway-database-postgresql:<flyway-core-version>") // required for PostgreSQL
def flywayUser = "postgres" // optional
def flywayPlaceholders = Task {
Map(
"org" -> "mill"
)
} // optional
// def flywayPassword = "" // optional
//endregion
}
Flyway will look for migration files in db/migration in all resources folders by default.
This should work regardless of if you are using a mill or sbt project layout.
You can then run common flyway commands like
> mill foo.flywayClean
> mill foo.flywayInfo
> mill foo.flywayMigrate
Set flywayDriverDeps to your JDBC driver dependency.
If your database requires an external Flyway plugin (for example PostgreSQL or MySQL in Flyway 11+),
set flywayPluginDeps to the matching Flyway database plugin dependency.
Use the same version as the bundled flyway-core dependency.
You should never hard-code credentials or check them into a version control system.
You should write some code to populate the settings for flyway instead.
For example def flywayPassword = Task.Input(Task.ctx.env("FLYWAY_PASSWORD"))
|