added migrations back + removed distracting log message

This commit is contained in:
2026-01-17 22:53:35 +01:00
parent cfd77ae28d
commit 502955d32f
2 changed files with 6 additions and 2 deletions

View File

@@ -25,7 +25,6 @@ func OpenDatabase() (models.IDatabase, error) {
}
func Migrate() error {
return nil
dbHost := helper.GetEnv("POSTGRES_HOST", "localhost")
dbName := helper.GetEnv("POSTGRES_DB", "arbeitszeitmessung")
// dbUser := helper.GetEnv("POSTGRES_USER", "api_nutzer")

View File

@@ -5,6 +5,7 @@ import (
"arbeitszeitmessung/helper"
"arbeitszeitmessung/models"
"context"
"database/sql"
"log/slog"
"net/http"
"os"
@@ -47,6 +48,8 @@ func main() {
return
}
defer models.DB.(*sql.DB).Close()
err = Migrate()
if err != nil {
slog.Error("Failed to migrate the database to newest version", "Error", err)
@@ -86,7 +89,9 @@ func ParamsMiddleware(next http.HandlerFunc) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
queryParams := r.URL.Query()
ctx := context.WithValue(r.Context(), "urlParams", queryParams)
slog.Debug("ParamsMiddleware added urlParams", slog.Any("urlParams", queryParams))
if len(queryParams) > 0 {
slog.Debug("ParamsMiddleware added urlParams", slog.Any("urlParams", queryParams))
}
next.ServeHTTP(w, r.WithContext(ctx))
})
}