Made database handling a bit clearer
This commit is contained in:
parent
35624c0034
commit
3a39c0e64f
|
@ -27,14 +27,13 @@ fun main() = application {
|
||||||
state = WindowState(position = WindowPosition(Alignment.Center), size = DpSize(1000.dp, 800.dp)),
|
state = WindowState(position = WindowPosition(Alignment.Center), size = DpSize(1000.dp, 800.dp)),
|
||||||
) {
|
) {
|
||||||
File("data/db").mkdirs()
|
File("data/db").mkdirs()
|
||||||
DI.setRepository(JdbcSqliteDriver("jdbc:sqlite:data/db/Bankmeister.db").apply {
|
DI.setRepository(JdbcSqliteDriver("jdbc:sqlite:data/db/Bankmeister.db").also { driver ->
|
||||||
val schema = BankmeisterDb.Schema
|
BankmeisterDb.Schema.synchronous().also { schema ->
|
||||||
schema.synchronous().also {
|
|
||||||
if (File("data/db/Bankmeister.db").exists() == false) {
|
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)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue