db

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package db owns the shared PostgreSQL connection pool and schema migrations. All stores receive the single *sql.DB created here instead of opening their own SQLite files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Migrate

func Migrate(pool *sql.DB) error

Migrate applies all pending up-migrations against the given pool. The schema is unified (one Postgres database, FKs across what used to be 14 separate SQLite files), so the migration order is fixed by file numbering and matters — parents before children. Idempotent: re-running with no pending versions returns nil.

func Open

func Open(ctx context.Context, dsn string, maxWait time.Duration) (*sql.DB, error)

Open dials the Postgres pool and waits for it to accept connections. The pool may not be reachable at boot (the sidecar is still starting, or the gluetun netns was just recreated on port rotation), so it pings with exponential backoff up to maxWait instead of failing immediately.

sql.Open never actually connects; the loop below is what proves the DB is up.

Types

This section is empty.

Jump to

Keyboard shortcuts

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