From d25802f3bb3755e29ecbc6b2e099fcdf00ee55cb Mon Sep 17 00:00:00 2001 From: dankito Date: Mon, 9 Sep 2024 00:06:32 +0200 Subject: [PATCH] Fixed creating database if it does not exist yet --- .../desktopMain/kotlin/net/codinux/banking/ui/main.kt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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 80009e6..5bb8dfa 100644 --- a/composeApp/src/desktopMain/kotlin/net/codinux/banking/ui/main.kt +++ b/composeApp/src/desktopMain/kotlin/net/codinux/banking/ui/main.kt @@ -28,7 +28,14 @@ fun main() = application { ) { File("data/db").mkdirs() DI.setRepository(JdbcSqliteDriver("jdbc:sqlite:data/db/Bankmeister.db").apply { - val schema = BankmeisterDb.Schema.synchronous().migrate(this, BankmeisterDb.Schema.version, 4) + val schema = BankmeisterDb.Schema + schema.synchronous().also { + if (File("data/db/Bankmeister.db").exists() == false) { + it.create(this) + } + + it.migrate(this, schema.version, 4) + } }) App()