ADD: added dockerfiles and a logger for the backend

This commit is contained in:
hwinkel
2025-12-15 13:30:41 +01:00
parent 7ec17e1e8b
commit 435ad8e6e6
12 changed files with 183 additions and 19 deletions

View File

@@ -5,6 +5,7 @@ import (
"fmt"
"log"
"studia/internal/config"
"studia/internal/logger"
_ "github.com/lib/pq" // Import the PostgreSQL driver
)
@@ -22,7 +23,7 @@ func New(cfg *config.Config) *sql.DB {
WHERE table_schema = 'public'
`)
if err != nil {
log.Println("failed to query existing tables:", err)
logger.Log.Error().Err(err).Msg("Failed to query existing tables")
}
missing := checkTables(expectedTables, existing)
@@ -32,7 +33,7 @@ func New(cfg *config.Config) *sql.DB {
// Here you would normally run migrations to create the missing tables
// For simplicity, we just log the missing tables
} else {
log.Println("All expected tables are present.")
logger.Log.Info().Msg("All expected tables are present.")
}
return db
@@ -41,7 +42,7 @@ func New(cfg *config.Config) *sql.DB {
func setupDatabase(cfg *config.Config) *sql.DB {
// Database connection setup logic here
log.Println(cfg)
logger.Log.Println(cfg)
switch cfg.DatabaseDriver {
case "postgres":
// Setup Postgres connection