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 ¶
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 ¶
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.