Documentation
¶
Overview ¶
Package db exposes the SQLite schema migrations as an embedded filesystem so the chassis binary can boot anywhere without needing the repo checkout on disk. The on-disk files under schema/sqlite/ are still the source of truth — they're embedded at compile time.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var FS embed.FS
FS contains the per-DB migration sets, embedded into the binary at build time. main.go reads from this when no explicit --db-schema-dir is provided (or when the provided dir doesn't exist).
auth/ holds the identity tables (actors, keys, memberships, invitations, browser_*). runtime/ holds the content tables (ops, tenants, stacks/versions/files). Each subdirectory is swept against its own *sql.DB with its own changeset row in varvals.
schema/postgres/auth mirrors schema/sqlite/auth for when the auth DSN is a postgres:// URL (the in-tree default stays SQLite — the runtime DB is always SQLite in open-core; the cloud overlay owns the Postgres runtime schema). See chassis/auth/registry dialect seam.
var SystemOpstacksFS embed.FS
SystemOpstacksFS is the default, chassis-shipped system opstack bundle, embedded at build time so a fresh chassis routes correctly with zero files on disk. Layout mirrors the CLI bundle convention:
opstacks/<_slug>/OPS/<stack>/<scope>/<name>.txcl
Only `_`-prefixed slugs are system (chassis-local, trusted) tenants. `_sys` owns the ingress-fallback `boot` stack. An operator can override/extend this from a local directory (see chassis/sysops); the embedded copy is the open-core baseline, exactly as schema/sqlite is the embedded baseline overridable by --db-schema-dir.
`all:` is required because go:embed otherwise skips `_`-prefixed entries — and every system tenant dir is literally `_`-prefixed (`_sys`, future `_playground`, …).
Functions ¶
func ApplyRuntimeSQLite ¶ added in v0.2.22
ApplyRuntimeSQLite applies the embedded SQLite runtime schema (schema/sqlite/runtime/*.sql, in numeric order) directly to db. It is the schema half of the dbcache Postgres mirror loader: the mirror is a throwaway :memory: SQLite handle, so unlike the boot migration runner this does NO changeset/varvals bookkeeping — it just materializes the table shapes the hot-read path expects, into which the loader then copies rows from the authoritative Postgres store.
Ordering matters (later migrations ALTER/rebuild earlier tables); the NNNN_ prefixes are zero-padded so a lexical sort is the numeric order.
func RegisterRuntimePostgresSchema ¶ added in v0.2.22
RegisterRuntimePostgresSchema records the overlay's embedded Postgres runtime schema (its fs.FS and the root directory inside it that holds the NNNN_*.sql migration files). Called from the overlay's init().
Types ¶
This section is empty.