Made database handling a bit clearer

This commit is contained in:
dankito 2024-09-12 00:20:28 +02:00
parent 35624c0034
commit 3a39c0e64f
1 changed files with 4 additions and 5 deletions

View File

@ -27,14 +27,13 @@ fun main() = application {
state = WindowState(position = WindowPosition(Alignment.Center), size = DpSize(1000.dp, 800.dp)),
) {
File("data/db").mkdirs()
DI.setRepository(JdbcSqliteDriver("jdbc:sqlite:data/db/Bankmeister.db").apply {
val schema = BankmeisterDb.Schema
schema.synchronous().also {
DI.setRepository(JdbcSqliteDriver("jdbc:sqlite:data/db/Bankmeister.db").also { driver ->
BankmeisterDb.Schema.synchronous().also { schema ->
if (File("data/db/Bankmeister.db").exists() == false) {
it.create(this)
schema.create(driver)
}
it.migrate(this, schema.version, 4)
schema.migrate(driver, schema.version, 1)
}
})