From a99b8b38442b3bb160f7a0043ba6b2bba70cbd3b Mon Sep 17 00:00:00 2001 From: mkelvers Date: Wed, 13 May 2026 12:51:47 +0200 Subject: [PATCH] chore: remove unreachable functions --- internal/db/helpers.go | 20 +------------------- internal/db/sqlite.go | 17 ----------------- 2 files changed, 1 insertion(+), 36 deletions(-) diff --git a/internal/db/helpers.go b/internal/db/helpers.go index 544e6f6..d0f41f1 100644 --- a/internal/db/helpers.go +++ b/internal/db/helpers.go @@ -1,11 +1,6 @@ package db -import ( - "context" - "database/sql" - "errors" - "fmt" -) +import "database/sql" // NullStringOr returns n.String if valid and non-empty, otherwise fallback func NullStringOr(n sql.NullString, fallback string) string { @@ -24,16 +19,3 @@ func (r GetUserWatchListRow) DisplayTitle() string { return DisplayTitle(r.TitleEnglish, r.TitleJapanese, r.TitleOriginal) } -// BeginTx starts a transaction and returns the Queries wrapper bound to it -func BeginTx(ctx context.Context, db *sql.DB) (*Queries, *sql.Tx, error) { - if db == nil { - return nil, nil, errors.New("database unavailable") - } - - tx, err := db.BeginTx(ctx, nil) - if err != nil { - return nil, nil, fmt.Errorf("failed to begin transaction: %w", err) - } - - return New(tx), tx, nil -} diff --git a/internal/db/sqlite.go b/internal/db/sqlite.go index db160cf..405eef1 100644 --- a/internal/db/sqlite.go +++ b/internal/db/sqlite.go @@ -4,7 +4,6 @@ import ( "database/sql" "fmt" "os" - "path/filepath" _ "github.com/mattn/go-sqlite3" ) @@ -26,19 +25,3 @@ func GetDBFile() string { return "mal.db" } -// GetMigrationsDir returns the migrations directory, checking MIGRATIONS_DIR env var first -func GetMigrationsDir() (string, error) { - if dir := os.Getenv("MIGRATIONS_DIR"); dir != "" { - return dir, nil - } - wd, err := os.Getwd() - if err != nil { - return "", fmt.Errorf("failed to get working directory: %w", err) - } - return filepath.Join(wd, "migrations"), nil -} - -// Init opens the database and returns a Queries instance -func Init(db *sql.DB) (*Queries, error) { - return New(db), nil -}