db

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package db provides Postgres connectivity and migrations for storage backends.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckHealth

func CheckHealth(ctx context.Context, pool *pgxpool.Pool, timeout time.Duration) error

CheckHealth performs a bounded ping against the Postgres pool.

func MigrationSourceURL

func MigrationSourceURL(path string) (string, error)

MigrationSourceURL converts a filesystem path to a migrate file:// URL.

func NewPool

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

NewPool creates and verifies a pgx connection pool from config.

Types

type MigrationRunner

type MigrationRunner struct {
	// contains filtered or unexported fields
}

MigrationRunner wraps golang-migrate operations for CLI and app tooling.

func NewMigrationRunner

func NewMigrationRunner(databaseURL, sourceURL string) (*MigrationRunner, error)

NewMigrationRunner creates a migrate runner for a source and database URL.

func (*MigrationRunner) Close

func (r *MigrationRunner) Close() error

Close closes migrate source and database handles.

func (*MigrationRunner) Down

func (r *MigrationRunner) Down(steps int) (bool, error)

Down rolls back the requested number of migration steps.

func (*MigrationRunner) Force

func (r *MigrationRunner) Force(version int) error

Force sets migrate state to a specific version.

func (*MigrationRunner) Up

func (r *MigrationRunner) Up() (bool, error)

Up applies all pending migrations.

func (*MigrationRunner) Version

func (r *MigrationRunner) Version() (MigrationVersion, error)

Version returns current migration version and dirty state.

type MigrationVersion

type MigrationVersion struct {
	// Version is the applied migration version when HasVersion is true.
	Version uint
	// Dirty indicates the database is marked dirty by migrate.
	Dirty bool
	// HasVersion reports whether any migration version is set.
	HasVersion bool
}

MigrationVersion describes the current migration state.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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