store

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package store is Panelarr's PostgreSQL data layer: a pgx pool, the embedded goose migrations and the sqlc queries in package db.

Panelarr keeps everything inside its own database. It never changes settings of the PostgreSQL server and needs no superuser: the role only has to own the database (or have CREATE on it).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MigrationResult

type MigrationResult struct {
	Version   int64
	Name      string
	Direction string
}

MigrationResult describes one applied migration.

type MigrationStatus

type MigrationStatus struct {
	Version int64
	Name    string
	Applied bool
}

MigrationStatus lists every migration and whether it is applied.

type Store

type Store struct {
	Pool *pgxpool.Pool
	*db.Queries
}

Store wraps the connection pool and the generated queries.

func Open

func Open(ctx context.Context, dsn string) (*Store, error)

Open connects to the database at dsn (a PostgreSQL URL or key=value string) and checks the connection.

func (*Store) Close

func (s *Store) Close()

Close closes the pool.

func (*Store) InTx

func (s *Store) InTx(ctx context.Context, f func(q *db.Queries, tx pgx.Tx) error) error

InTx runs f in a transaction and commits it if f returns nil.

func (*Store) Migrate

func (s *Store) Migrate(ctx context.Context) ([]MigrationResult, error)

Migrate applies all pending migrations. A Postgres advisory lock keeps several server instances from migrating at once.

func (*Store) MigrateDown

func (s *Store) MigrateDown(ctx context.Context) ([]MigrationResult, error)

MigrateDown rolls back the latest migration.

func (*Store) Status

func (s *Store) Status(ctx context.Context) ([]MigrationStatus, error)

Status reports which migrations are applied.

Directories

Path Synopsis
Package storetest gives tests a fresh, migrated PostgreSQL database.
Package storetest gives tests a fresh, migrated PostgreSQL database.

Jump to

Keyboard shortcuts

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