fix: remove db utils

This commit is contained in:
2024-12-04 22:13:59 +01:00
parent 521119fc02
commit 3ee26cd32b
4 changed files with 12 additions and 14 deletions

View File

@@ -7,7 +7,6 @@ import (
"me-fit/middleware"
"me-fit/service"
"me-fit/types"
"me-fit/utils"
"context"
"database/sql"
@@ -38,7 +37,7 @@ func main() {
run(context.Background(), db, os.Getenv)
}
func run(ctx context.Context, db *sql.DB, env func(string) string) {
func run(ctx context.Context, database *sql.DB, env func(string) string) {
ctx, cancel := signal.NotifyContext(ctx, syscall.SIGINT, syscall.SIGTERM)
defer cancel()
@@ -48,7 +47,7 @@ func run(ctx context.Context, db *sql.DB, env func(string) string) {
serverSettings := types.NewServerSettingsFromEnv(env)
// init db
err := utils.RunMigrations(db, "")
err := db.RunMigrations(database, "")
if err != nil {
log.Error("Could not run migrations: %v", err)
os.Exit(1)
@@ -66,7 +65,7 @@ func run(ctx context.Context, db *sql.DB, env func(string) string) {
httpServer := &http.Server{
Addr: ":" + serverSettings.Port,
Handler: createHandler(db, serverSettings),
Handler: createHandler(database, serverSettings),
}
go startServer(httpServer)