db

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 23, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MigrateDownAll

func MigrateDownAll(migrationsFS fs.FS, databaseURL string) error

MigrateDownAll rolls back every applied migration. It is destructive and used only by the migration round-trip test and the guarded `legant migrate down` command — never in normal operation.

func MigrationStatus

func MigrationStatus(migrationsFS fs.FS, databaseURL string) (version uint, dirty bool, err error)

MigrationStatus reports the current migration version and dirty flag, for readiness checks. A dirty database is not ready to serve.

func NewPool

func NewPool(ctx context.Context, cfg config.DatabaseConfig) (*pgxpool.Pool, error)

func RunMigrations

func RunMigrations(migrationsFS fs.FS, databaseURL string) error

RunMigrations applies all pending migrations. It refuses to proceed if the schema_migrations table is marked dirty (a prior migration failed mid-way), which must be resolved by an operator rather than silently retried.

func WithTx

func WithTx(ctx context.Context, pool *pgxpool.Pool, fn func(pgx.Tx) error) error

WithTx runs fn inside a database transaction, committing on success and rolling back on any error or panic. Security-critical writes (e.g. minting an exchanged token together with its audit record) use this so the two either both commit or neither does.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL