Fixed some small bugs after merge

This commit is contained in:
2026-06-14 11:30:58 +02:00
parent 0894d65ec5
commit 4e5bdc4ee2
21 changed files with 1460 additions and 186 deletions
+21
View File
@@ -4,6 +4,7 @@ import (
"context"
"database/sql"
"fmt"
"time"
"music-server/internal/logging"
@@ -59,6 +60,26 @@ func (db *Database) Close() {
}
}
// Health checks the health of the database connection by pinging the database.
// It returns a map with keys indicating various health statistics.
func (db *Database) Health() map[string]string {
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
defer cancel()
stats := make(map[string]string)
// Ping the database
err := db.Pool.Ping(ctx)
if err != nil {
stats["status"] = "down"
stats["error"] = err.Error()
return stats
}
stats["status"] = "up"
return stats
}
// RunMigrations runs all pending database migrations to the latest version.
// Uses the existing pool to extract connection details.
func (db *Database) RunMigrations() error {