doobie-flyway

build Release Notes Maven Central Apache License 2.0 Scala Steward badge

Flyway migrations for doobie.

build.sbt

libraryDependencies += "de.lhns" %% "doobie-flyway" % "0.4.0"

Usage

def transactor(config: DbConfig): Resource[IO, Transactor[IO]] =
  for {
    ce <- ExecutionContexts.fixedThreadPool[IO](config.poolSizeOrDefault)
    xa <- HikariTransactor
            .newHikariTransactor[IO](
              config.driverOrDefault,
              config.url,
              config.user,
              config.password,
              ce
            )
    _  <- Flyway(xa) { flyway =>
            for {
              info <- flyway.info()
              _    <- flyway
                        .configure(_
                          .withBaselineMigrate(info)
                          .validateMigrationNaming(true)
                        )
                        .migrate()
            } yield ()
          }
  } yield xa

License

This project uses the Apache 2.0 License. See the file called LICENSE.