I'm using MySQL database, and have this code for m...
# squarelibraries
p
I'm using MySQL database, and have this code for migration:
Copy code
val 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.
a
definitely sounds like a bug, we should add a test to the drivers that verifies a created table is rolled back if theres a crash in the transaction