// Package migrations embeds the SQL schema migrations and applies them with goose. package migrations import ( "context" "embed" "fmt" "github.com/jackc/pgx/v5/pgxpool" "github.com/jackc/pgx/v5/stdlib" "github.com/pressly/goose/v3" ) //go:embed *.sql var files embed.FS // Up applies all pending migrations. func Up(ctx context.Context, pool *pgxpool.Pool) error { db := stdlib.OpenDBFromPool(pool) defer db.Close() p, err := goose.NewProvider(goose.DialectPostgres, db, files) if err != nil { return fmt.Errorf("goose provider: %w", err) } if _, err := p.Up(ctx); err != nil { return fmt.Errorf("migrate up: %w", err) } return nil }