| 1 | // Package db compiles every service's migrations into its binary, so an image |
| 2 | // always carries exactly the schema its code was written for. |
| 3 | package db |
| 4 | |
| 5 | import ( |
| 6 | "embed" |
| 7 | "io/fs" |
| 8 | "path" |
| 9 | ) |
| 10 | |
| 11 | //go:embed */migrations/*.sql |
| 12 | var files embed.FS |
| 13 | |
| 14 | // Migrations returns one service's migrations, from db/<service>/migrations. |
| 15 | func Migrations(service string) fs.FS { |
| 16 | sub, err := fs.Sub(files, path.Join(service, "migrations")) |
| 17 | if err != nil { |
| 18 | panic(err) // only for a name that isn't a valid path |
| 19 | } |
| 20 | return sub |
| 21 | } |