refactor(core): Unify components and adopt standard tooling

This commit performs several key refactorings within the `core`-module to improve consistency, stability, and adhere to industry best practices.

1.  **Unify `Result` Type:**
    Removed the specialized `Result<T>` class from `core-utils`. The entire system will now exclusively use the more flexible and type-safe `Result<T, E>` from `core-domain`. This allows for explicit, non-exception-based error handling for business logic.

2.  **Adopt Flyway for Database Migrations:**
    Replaced the custom `DatabaseMigrator.kt` implementation with the industry-standard tool Flyway. The `DatabaseFactory` now triggers Flyway migrations on application startup. This provides more robust, transactional, and feature-rich schema management.

3.  **Cleanup and Housekeeping:**
    - Removed obsolete test files related to the old migrator.
    - Ensured all components align with the new unified patterns.

BREAKING CHANGE: The `at.mocode.core.utils.error.Result` class has been removed. All modules must be updated to use the `at.mocode.core.domain.error.Result` type. The custom migrator is no longer available.

Closes #ISSUE_NUMBER_FOR_REFACTORING
This commit is contained in:
2025-07-28 22:43:28 +02:00
parent ca4d476360
commit 260460149a
13 changed files with 477 additions and 699 deletions
@@ -1,5 +1,7 @@
package at.mocode.masterdata.service
import at.mocode.core.utils.config.AppConfig
import at.mocode.core.utils.database.DatabaseFactory
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication
@@ -11,9 +13,18 @@ import org.springframework.boot.runApplication
@SpringBootApplication
class MasterdataServiceApplication
/**
* Main entry point for the Masterdata Service application.
*/
fun main(args: Array<String>) {
// 1. Lade die Konfiguration explizit, genau einmal beim Start.
val appConfig = AppConfig.load()
println("Konfiguration für Umgebung '${appConfig.environment}' geladen.")
// 2. Initialisiere die Datenbank mit der geladenen Konfiguration.
// Flyway-Migrationen werden hier automatisch ausgeführt.
DatabaseFactory.init(appConfig.database)
println("Datenbank initialisiert und migriert.")
// 3. Starte die Spring Boot / Ktor Anwendung.
// Der appConfig-Wert kann hier an die Anwendung übergeben werden,
// um ihn später per Dependency Injection zu nutzen.
runApplication<MasterdataServiceApplication>(*args)
}