Created
October 19, 2018 16:00
-
-
Save rkrzewski/148963de56e453fc3cb25d4c8bf21a23 to your computer and use it in GitHub Desktop.
Liquibase migration with Doobie
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cats._ | |
import doobie._ | |
import doobie.implicits._ | |
import liquibase.Liquibase | |
import liquibase.database.DatabaseFactory | |
import liquibase.database.jvm.JdbcConnection | |
import liquibase.resource.ClassLoaderResourceAccessor | |
object LiquibaseMigration { | |
def run[F[_]: Monad](xa: Transactor[F]): F[Unit] = | |
FC.raw { conn => | |
val resourceAccessor = new ClassLoaderResourceAccessor( | |
getClass().getClassLoader()) | |
val database = DatabaseFactory.getInstance() | |
.findCorrectDatabaseImplementation(new JdbcConnection(conn)) | |
val liquibase = new Liquibase("META-INF/schema-changelog.xml", resourceAccessor, database) | |
liquibase.update("") | |
}.transact(xa) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment