Hi everyone. Can anyone share their experience on...
# exposed
a
Hi everyone. Can anyone share their experience on handling migrations while using Exposed? I've worked on a Spring Boot (Java) project recently and we used Liquidbase for this purpose. I'm working on a new Ktor API and I intend to use Exposed for DB access. Thanks in advance.
j
Exposed only has a very basic migration tool, I generally use Liquibase with Exposed, which isn't terribly difficult to do even without the Spring Boot integration
l
We used Exposed for migrations early in the project but quickly found it to be insufficient. We are now using Liquibase and are very happy with it.
s
The Exposed team is working on proper migration support in 0.60.0 they introduced
migration-exposed
which allows generating a migration statements, and scripts from Kotlin code, and they're now building a Gradle plugin around it. Not sure if it'll make it in before 1.0.0, but might soon after in 1.1.0. https://github.com/JetBrains/Exposed/pull/2451 It's focusing on Flyway first, but Liquibase might be on the roadmap soon depending on feature requests. Most likely through it's SQL support.
d
In my case, while developing exposed is very useful, but after releasing, it doesn't support run SQL for editing exist data so I have to use flyway for migrating existing data
a
Thanks everyone for sharing your experiences. Much appreciated. I'm not sure how to go about it yet, don't think there's a documentation for the exposed-migration module. But I'll try using Flyway / Liquidbase and see how it goes.
d
I'm using both
Copy code
val statements = MigrationUtils.statementsRequiredForDatabaseMigration(*tables)
if (statements.isNotEmpty()) {
    TransactionManager.current().execInBatch(statements)
}
If there is any migration that need run plain SQL(like foreign key conflict) then I will use flyway before migrating
a
Thanks @Duc 🙏🏾