Documentation
¶
Overview ¶
Package pgdb opens a PostgreSQL connection pool and helps with transactions.
It stays deliberately thin: queries are written by generators (sqlc for static ones, jet for dynamic ones) and only the parts identical in every project live here.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InTx ¶
InTx runs fn inside a transaction: it rolls back on error or panic and commits otherwise.
func Migrate ¶ added in v0.2.0
func Migrate(ctx context.Context, pool *pgxpool.Pool, fsys fs.FS, log *slog.Logger) ([]string, error)
Migrate applies the pending SQL migrations from fsys and returns the files it applied.
Migrations are goose files ("-- +goose Up"). A session advisory lock is held while they run, so several instances starting at once apply each migration exactly once. Files other than *.sql are ignored: the embedded directory also holds its Go file.