From 0482ef8479a0a4b52f9049317f70b4e85c8fd9d9 Mon Sep 17 00:00:00 2001 From: stefan Date: Thu, 5 Jun 2025 14:38:32 +0200 Subject: [PATCH] fix SQLite --- docker-compose.yml | 2 ++ server/src/main/kotlin/at/mocode/plugins/Database.kt | 9 ++++++--- server/src/main/kotlin/at/mocode/routes/AdminRoutes.kt | 3 ++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index ab476f78..8231b823 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,6 +9,8 @@ services: - "8080:8081" volumes: - sqlite_data:/app/data # Volume für SQLite Datenbank + environment: + - USE_SQLITE=true networks: - meldestelle-net diff --git a/server/src/main/kotlin/at/mocode/plugins/Database.kt b/server/src/main/kotlin/at/mocode/plugins/Database.kt index fb64169d..afe0792f 100644 --- a/server/src/main/kotlin/at/mocode/plugins/Database.kt +++ b/server/src/main/kotlin/at/mocode/plugins/Database.kt @@ -37,12 +37,15 @@ fun configureDatabase() { throw e // Rethrow error, test should fail } } else { - // Check if we're running in IDEA (no Docker environment variables set) - // We only check one variable, that's usually enough + // Check if we should use SQLite (either in IDEA or in Docker with SQLite) + // First check for explicit SQLite flag + val useSqlite = System.getenv("USE_SQLITE")?.toBoolean() ?: false + + // Then check if we're in IDEA (no Docker environment variables set) val dbHostFromEnv = System.getenv("DB_HOST") val isIdeaEnvironment = (dbHostFromEnv == null) - if (isIdeaEnvironment) { + if (useSqlite || isIdeaEnvironment) { // Ensure the data directory exists val dataDir = File("data") if (!dataDir.exists()) { diff --git a/server/src/main/kotlin/at/mocode/routes/AdminRoutes.kt b/server/src/main/kotlin/at/mocode/routes/AdminRoutes.kt index 2f2f7097..1e30e9e6 100644 --- a/server/src/main/kotlin/at/mocode/routes/AdminRoutes.kt +++ b/server/src/main/kotlin/at/mocode/routes/AdminRoutes.kt @@ -1,6 +1,7 @@ package at.mocode.routes import at.mocode.model.Bewerb +import at.mocode.config.DependencyInjection import at.mocode.repository.TurnierRepository import at.mocode.views.AdminView import io.ktor.http.* @@ -15,7 +16,7 @@ import org.slf4j.LoggerFactory */ fun Route.adminRoutes() { val log = LoggerFactory.getLogger("AdminRoutes") - val turnierRepository = TurnierRepository() + val turnierRepository = DependencyInjection.turnierRepository val adminView = AdminView() // Route to display the tournament management page