Go · 718 bytes Raw Blame History
1 // SPDX-License-Identifier: AGPL-3.0-or-later
2
3 // Package migrationsfs embeds the SQL migrations from the repo root and
4 // registers them with the db package. It exists as its own package because
5 // //go:embed paths can't traverse upward; the migrationsfs/ directory is at
6 // the right level relative to migrations/ to embed it.
7 package migrationsfs
8
9 import (
10 "embed"
11 "io/fs"
12
13 "github.com/tenseleyFlow/shithub/internal/infra/db"
14 )
15
16 //go:embed all:migrations
17 var migrationsFS embed.FS
18
19 // FS returns the embedded migrations filesystem rooted at "migrations/".
20 func FS() fs.FS {
21 sub, err := fs.Sub(migrationsFS, "migrations")
22 if err != nil {
23 panic(err)
24 }
25 return sub
26 }
27
28 func init() {
29 db.SetMigrationsFS(FS())
30 }
31