humblehacker
03/31/2023, 9:33 PMupgrade
block on DatabaseConfiguration
).
So any pointers on where I should look or any other things to try would be greatly appreciated!humblehacker
04/01/2023, 2:45 AMextendedConfig = DatabaseConfiguration
.Extended(foreignKeyConstraints = true)
The migration works fine. I tried turning it back on and adding
upgrade = { connection, oldVersion, newVersion -> connection.updateForeignKeyConstraints(false)
wrapConnection(connection) {
Database.Schema.migrate(it, oldVersion, newVersion)
}
},
extendedConfig = DatabaseConfiguration.Extended(foreignKeyConstraints = true)
hoping it would turn them off for the migrations only, but that had no effect.humblehacker
04/01/2023, 2:17 PMupgrade
block is called within a transaction, and This pragma is a no-op within a transaction.humblehacker
04/01/2023, 2:17 PMhumblehacker
04/01/2023, 3:41 PMupgrade
block so it doesn't try to migrate again. It seems to work, inasmuch as my app starts with all it's data intact. Still testing to see if there are any unintended side-effects.
// Workaround for failure to copy data during migrations with foreign keys enabled
NativeSqliteDriver(schema = schema, name = Constants.databaseName).close()
val nativeDriver = NativeSqliteDriver(
schema = schema,
name = Constants.databaseName,
onConfiguration = { config ->
config.copy(
upgrade = { _, _, _ -> },
extendedConfig = DatabaseConfiguration.Extended(foreignKeyConstraints = true)
)
}
)
humblehacker
04/01/2023, 3:45 PMINSERT INTO tableNew SELECT * FROM tableOld
fails to copy any data for all but one table.