From 3a39c0e64fc09d7fc6661c48abb33ce390829bd7 Mon Sep 17 00:00:00 2001 From: dankito Date: Thu, 12 Sep 2024 00:20:28 +0200 Subject: [PATCH] Made database handling a bit clearer --- .../desktopMain/kotlin/net/codinux/banking/ui/main.kt | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/composeApp/src/desktopMain/kotlin/net/codinux/banking/ui/main.kt b/composeApp/src/desktopMain/kotlin/net/codinux/banking/ui/main.kt index 5bb8dfa..ae9e4f6 100644 --- a/composeApp/src/desktopMain/kotlin/net/codinux/banking/ui/main.kt +++ b/composeApp/src/desktopMain/kotlin/net/codinux/banking/ui/main.kt @@ -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) } })