Documentation
¶
Overview ¶
Package sqlite is the pure-Go SQLite Repository driver — the lightweight / embedded backend tier (single file or :memory:), sitting between Postgres (production, multi-node) and memory (tests). It uses modernc.org/sqlite (NO cgo) so the embeddable library cross-compiles cleanly.
The driver implements service.Repository over the SQLite data plane (every row scoped by `WHERE project_id = $1`, the backend-agnostic isolation boundary — ADR-0002) and satisfies service.DB with the same no-op graph surface the memory driver uses. The control plane (projects registry beyond the boot default, tenants, domains, governance) is Postgres-only; SQLite targets the single-project embedded tier, so it keeps only a `projects` table to anchor the project_id FK chain and the EnsureDefaultProject boot seed.
Schema lives in migrations/ as a squashed final-state SQL file, applied on New() via golang-migrate's pure-Go sqlite driver. JSONB columns are stored as TEXT; partial/expression indexes are preserved; there is no RLS (that stays Postgres-only defense-in-depth).
Index ¶
Constants ¶
const DefaultMaxConns = 4
DefaultMaxConns is used when Config.MaxConns is zero. SQLite is a single-writer engine, so a small pool is plenty for the embedded tier.
const MemoryPath = ":memory:"
MemoryPath is the sentinel Path value selecting an in-memory database.
Variables ¶
This section is empty.
Functions ¶
func New ¶
New opens (or creates) the SQLite database at cfg.Path, applies pending migrations, and returns a project-scoped repository. The returned store implements both service.Repository and service.DB.
For an on-disk path the file is created if missing. For an in-memory database (cfg.Path == ":memory:") the store is bound to a single shared connection so every query sees the same database — a fresh connection to ":memory:" would otherwise get an independent empty database.
Types ¶
type Config ¶
Config controls how the SQLite repository opens its database.
Path is either a filesystem path (created if missing) or the literal ":memory:" for an ephemeral in-process database. MaxConns caps the connection pool for on-disk databases; in-memory databases are always pinned to a single connection (see New). ProjectID is the project (storage shard) this instance binds to — every data-plane row carries it and the mandatory `WHERE project_id = $1` predicate is bound here (ADR-0002).
Source Files
¶
- config.go
- db.go
- email_change.go
- email_verification.go
- errors.go
- identity_verification.go
- invitation.go
- login_challenge.go
- migrations.go
- oauth_identity.go
- oauth_one_time_code.go
- passkey.go
- password_reset.go
- passwordless.go
- phone.go
- qr_login.go
- recovery_code.go
- refresh_token.go
- repo.go
- session.go
- sqldb.go
- sweeper.go
- totp.go
- user.go