Documentation
¶
Overview ¶
Package database provides shared SQLite helpers for schema migration and connection management. All stores that open or migrate SQLite databases should use these helpers for consistency.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddColumn ¶
AddColumn idempotently adds a column to an existing table. If the column already exists the call is a no-op. The typedef parameter is the SQL type and optional constraints, for example "TEXT" or "INTEGER DEFAULT 0".
func HasColumn ¶
HasColumn reports whether the given table contains a column with the specified name. It uses a lightweight SELECT probe that avoids scanning any rows. Identifiers are left unquoted because SQLite treats double-quoted unknown identifiers as string literals, which would make the probe always succeed.
func Open ¶
Open opens a SQLite database at the given path with standard production settings: WAL journal mode and a 5-second busy timeout. Callers must ensure the github.com/mattn/go-sqlite3 driver is registered (typically via a blank import in the binary's main package or test file).
func OpenMemory ¶ added in v0.9.1
OpenMemory opens an isolated shared-cache in-memory SQLite database suitable for tests. Each call gets a unique database name so parallel test packages cannot contaminate each other. MaxOpenConns and MaxIdleConns are set to 1 to prevent the pool from dropping the last connection and silently losing the in-memory state.
Types ¶
This section is empty.