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 +}