db

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package db opens the Postgres pool and runs schema migrations (goose for ReputeCast's own tables, rivermigrate for River's job tables).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HasPending

func HasPending(ctx context.Context, pool *pgxpool.Pool, logger *slog.Logger) (bool, error)

HasPending reports whether any goose migration is not yet applied.

func MigrateDown

func MigrateDown(ctx context.Context, pool *pgxpool.Pool, logger *slog.Logger) error

MigrateDown rolls back the latest goose migration.

func MigrateUp

func MigrateUp(ctx context.Context, pool *pgxpool.Pool, logger *slog.Logger) error

MigrateUp applies all pending goose migrations, then River's migrations.

func Open

func Open(ctx context.Context, url string, maxConns int32) (*pgxpool.Pool, error)

Open creates a connection pool and verifies the database is reachable.

func Tx

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

Tx runs fn inside a transaction, committing on success and rolling back on error or panic.

Types

type MigrationStatus

type MigrationStatus struct {
	Version   int64
	Name      string
	Applied   bool
	AppliedAt time.Time
}

MigrationStatus describes one goose migration.

func Status

func Status(ctx context.Context, pool *pgxpool.Pool, logger *slog.Logger) ([]MigrationStatus, error)

Status lists goose migrations and whether they are applied.

Jump to

Keyboard shortcuts

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