refactor: consolidate applyMigrations into single exported function
All checks were successful
check / check (push) Successful in 1m8s

Remove the unexported applyMigrations() and the runMigrations() method.
ApplyMigrations() is now the single implementation, accepting context
and an optional logger. connect() calls it directly.

All callers updated to pass context.Background() and nil logger.
This commit is contained in:
user
2026-03-17 01:51:46 -07:00
parent 63f8cd1bd0
commit 6a248756b5
5 changed files with 13 additions and 21 deletions

View File

@@ -16,7 +16,7 @@ func setupStatsTestDB(t *testing.T) *sql.DB {
if err != nil {
t.Fatal(err)
}
if err := database.ApplyMigrations(db); err != nil {
if err := database.ApplyMigrations(context.Background(), db, nil); err != nil {
t.Fatal(err)
}
t.Cleanup(func() { db.Close() })

View File

@@ -2,6 +2,7 @@ package imgcache
import (
"bytes"
"context"
"database/sql"
"image"
"image/color"
@@ -193,7 +194,7 @@ func setupServiceTestDB(t *testing.T) *sql.DB {
}
// Use the real production schema via migrations
if err := database.ApplyMigrations(db); err != nil {
if err := database.ApplyMigrations(context.Background(), db, nil); err != nil {
t.Fatalf("failed to apply migrations: %v", err)
}