Expand description
The physical schema and its versioned, forward-only migrations.
Every statement runs on rusqlite and on Durable Object SQLite: no
ATTACH, no PRAGMA, no transaction control. The version lives in the
one-row mkit_schema table (not PRAGMA user_version, which Durable
Objects do not allow).
Logical layout changes (new key classes, new row kinds) need no
physical migration: they are key layouts, versioned by the v row
(store::keys::layout_version). A physical migration changes only the
kv table’s shape.
Physical v1: one kv table keyed by (part, key). part is the
Partition::encode bytes, so one native
file holds every partition (a D34 shard is a part value); a Durable
Object holds one partition, and the column is constant there. It is a
BLOB, not TEXT: the encoding’s components end in 0x00, which
SQLite text functions treat as a terminator.
Physical v2 adds kv_timers, a partial index over the timer rows
(w 00 …) that lets a backend find each partition’s earliest timer.
It is index-only, but a binary built before v2 refuses a v2 database
(“schema is newer than this binary”): roll back only to a v2 binary.
Structs§
- Migration
- One physical migration: its statements run in one transaction, which
then records
version.
Constants§
- BOOTSTRAP
- The version table, created before anything reads it.
- MIGRATIONS
- Every migration, in ascending version order.
- SCHEMA_
VERSION - The schema version this binary expects: the last migration’s.
Functions§
- migrate
- Bring the database to
SCHEMA_VERSION; returns the version reached. Each missing migration runs in its own transaction, which re-reads the version first, so concurrent openers apply it once. Idempotent. - require_
current - Check an existing database without applying migrations or writing schema rows.