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 ae9e4f6..2eaca16 100644 --- a/composeApp/src/desktopMain/kotlin/net/codinux/banking/ui/main.kt +++ b/composeApp/src/desktopMain/kotlin/net/codinux/banking/ui/main.kt @@ -7,6 +7,7 @@ import androidx.compose.ui.unit.DpSize import androidx.compose.ui.unit.dp import androidx.compose.ui.window.* import app.cash.sqldelight.async.coroutines.synchronous +import app.cash.sqldelight.db.SqlDriver import app.cash.sqldelight.driver.jdbc.sqlite.JdbcSqliteDriver import bankmeister.composeapp.generated.resources.AppIcon_svg import bankmeister.composeapp.generated.resources.Res @@ -26,21 +27,27 @@ fun main() = application { icon = painterResource(Res.drawable.AppIcon_svg), 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").also { driver -> - BankmeisterDb.Schema.synchronous().also { schema -> - if (File("data/db/Bankmeister.db").exists() == false) { - schema.create(driver) - } - - schema.migrate(driver, schema.version, 1) - } - }) + DI.setRepository(createSqlDriverDriver()) App() } } +private fun createSqlDriverDriver(): SqlDriver { + File("data/db").mkdirs() + + return JdbcSqliteDriver("jdbc:sqlite:data/db/Bankmeister.db").also { driver -> + BankmeisterDb.Schema.synchronous().also { schema -> + if (File("data/db/Bankmeister.db").exists() == false) { + schema.create(driver) + } + + schema.migrate(driver, schema.version, 1) + } + } +} + + @Preview @Composable fun AppPreview() {