Skip to main content

Module db

Module db 

Source
Expand description

SQLite helpers (kernel spec §1).

Structs§

ConnectionGuard
CoordinatedConnection
Store mutex with a fixed ordering: owner gate, then the connection.
OwnedConnection
A SQLite connection retaining its process ownership. Dereferencing it exposes SQLite only while the ownership handle remains alive.

Functions§

kernel_owner
Migrate the kernel’s tables (schema), then return the database’s owner (plan 3b-iii decisions 1 and 2): the oldest row of owners, which the kernel’s migrations create at the first start. Every store on hennery.db binds to it when it opens, so they agree whichever opens first. This is the one query that does not filter by the owner: it finds the owner.
migrate
Apply migrations[user_version..] in order, each in its own transaction. Refuses to run against a database newer than this binary.
migrate_component
Like migrate, for one component of a database that several own (kernel spec §1): the kernel’s tables share hennery.db with the sessions module, which keeps user_version for itself. Each component’s version is a row of schema_versions, and a component newer than this binary is refused the same way. Each step reads the version inside its transaction, as migrate does.
open
Open (or create) a database with the pragmas every hennery database uses.
open_in_memory