Philip Dukhov
12/02/2021, 11:56 AMval dataSource = HikariDataSource(datasourceConfig)
val driver = dataSource.asJdbcDriver()
driver.migrate(Database.Schema)
//...
private class SqlDriverTransacter(driver: SqlDriver) : TransacterImpl(driver)
fun SqlDriver.migrate(schema: SqlDriver.Schema) {
val sqlDriverTransacter = SqlDriverTransacter(this)
// ...
sqlDriverTransacter.transaction {
// ...
}
}
I don't remember exactly where from this code came from, it looks kind of like this one.
The problem is that in case of a crash inside transaction
, the database is not getting rolled back. When in my migration I have create table
and then some action, if the action fails, next time I'm getting a crash Table already exists
.
I've tried catching the error inside transaction
and running rollback
manually, but this had no effect.alec
12/02/2021, 3:21 PM