db

package
v0.2.22 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2026 License: MPL-2.0 Imports: 8 Imported by: 0

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

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.

View Source
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

func ApplyRuntimeSQLite(db *sql.DB) error

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

func RegisterRuntimePostgresSchema(fsys fs.FS, root string)

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().

func RuntimePostgresSchema added in v0.2.22

func RuntimePostgresSchema() (fsys fs.FS, root string, ok bool)

RuntimePostgresSchema returns the registered Postgres runtime schema (fs.FS, root) and whether one was registered. ok is false in an open-core binary that never blank-imported the overlay.

Types

This section is empty.

Jump to

Keyboard shortcuts

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