From 58fa790b2b49f5b337a5f82f0e630628df3eb948 Mon Sep 17 00:00:00 2001 From: bvandeusen Date: Sat, 18 Apr 2026 21:20:34 +0000 Subject: [PATCH] feat(skel): db package with embedded migrations stub MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Establishes the embed.FS and migrations/ layout up front. Migrate() returns ErrNotConfigured intentionally — the real goose runner lands in M2 alongside Postgres work, avoiding a toolchain bump to Go 1.24/1.25 through goose's transitive modernc.org/libc dependency chain. --- internal/db/db.go | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 internal/db/db.go diff --git a/internal/db/db.go b/internal/db/db.go new file mode 100644 index 00000000..587aab69 --- /dev/null +++ b/internal/db/db.go @@ -0,0 +1,33 @@ +package db + +import ( + "embed" + "errors" +) + +//go:embed migrations/*.sql +var migrationsFS embed.FS + +// MigrationsFS exposes the embedded migration files. The concrete migration +// runner (goose) will be wired in M2 when Postgres work begins; this package +// intentionally keeps the embed + a placeholder surface so the file layout +// and `go:embed` directive are established from day one. +func MigrationsFS() embed.FS { + return migrationsFS +} + +// ErrNotConfigured is returned by Migrate until the real runner is wired. +var ErrNotConfigured = errors.New("db: migrations not yet configured (wired in M2)") + +// Migrate is a placeholder. It validates that the embedded migrations load +// and then returns ErrNotConfigured so callers can detect the stub. +func Migrate() error { + entries, err := migrationsFS.ReadDir("migrations") + if err != nil { + return err + } + if len(entries) == 0 { + return errors.New("db: no migration files found") + } + return ErrNotConfigured +}