feat(backend): add transactional outbox and embedded goose migrations
This commit is contained in:
1 parent
653f3775f8
commit
15e2e50561
40 files changed
+2471
-67
No files matched your search
@@ -0,0 +1,25 @@
|
||||
// Package db embeds the versioned SQL migrations so the backend binary applies
|
||||
// exactly the schema it was built with. The SQL files stay in db/migrations,
|
||||
// where sqlc and sqlfluff also read them; go:embed cannot reach a parent
|
||||
// directory, so the embedding package lives next to that directory.
|
||||
package db
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
)
|
||||
|
||||
const migrationsDirectory = "migrations"
|
||||
|
||||
//go:embed migrations/*.sql
|
||||
var migrationFiles embed.FS
|
||||
|
||||
// Migrations returns the goose SQL migrations with file names at the root.
|
||||
func Migrations() (fs.FS, error) {
|
||||
migrations, err := fs.Sub(migrationFiles, migrationsDirectory)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("db.Migrations - open embedded migrations: %w", err)
|
||||
}
|
||||
return migrations, nil
|
||||
}
|
||||
Reference in new issue
Block a user