53 lines
2.2 KiB
SQL
53 lines
2.2 KiB
SQL
PRAGMA foreign_keys = ON;
|
|
|
|
-- ids are AUTOINCREMENT: rows can move between entries and records
|
|
-- (archive / unarchive), and ids must never be reused -- journal targets
|
|
-- stay meaningful forever.
|
|
CREATE TABLE IF NOT EXISTS entries (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
ring TEXT NOT NULL CHECK (ring IN ('a', 'b', 'cold')),
|
|
type TEXT NOT NULL CHECK (type IN ('place', 'person', 'fact', 'thread')),
|
|
label TEXT NOT NULL,
|
|
detail TEXT NOT NULL DEFAULT '',
|
|
created TEXT NOT NULL,
|
|
last_touched TEXT NOT NULL
|
|
);
|
|
|
|
CREATE INDEX IF NOT EXISTS entries_ring_touch
|
|
ON entries (ring, last_touched DESC, id DESC);
|
|
|
|
-- the character's files: cards, ledgers, manifests.
|
|
-- detailed, queryable, never bulk-loaded into context.
|
|
-- access is diegetic and per-run: settings.json {"records": bool}
|
|
CREATE TABLE IF NOT EXISTS records (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
kind TEXT NOT NULL,
|
|
label TEXT NOT NULL,
|
|
detail TEXT NOT NULL DEFAULT '',
|
|
created TEXT NOT NULL
|
|
);
|
|
|
|
-- her status and agenda lived here once (the paper model's runtime
|
|
-- half). Retired 2026-11-16: the log is the one truth -- the state
|
|
-- scan reads her blocks, and no db table holds a copy. Old runs keep
|
|
-- their dead tables on disk, never read, never dropped (Irene is
|
|
-- hands-off; dumps tolerate their presence, restore skips what the
|
|
-- schema lacks).
|
|
|
|
-- append-only audit journal; nothing here is ever updated or deleted.
|
|
-- target is 'e<id>' for entries, 'r<id>' for records.
|
|
-- prior captures the replaced state of a journaled mutator (the saga
|
|
-- rule): amend/discard carry the old record content -- so turn
|
|
-- surgery can compensate mechanically. The status/agenda op names
|
|
-- stay in the CHECK for the historical journals that used them.
|
|
CREATE TABLE IF NOT EXISTS events (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
session TEXT NOT NULL,
|
|
op TEXT NOT NULL CHECK (op IN ('insert', 'touch', 'promote', 'demote', 'reword', 'delete', 'evict', 'revive', 'record', 'archive', 'unarchive', 'amend', 'discard', 'status-add', 'status-drop', 'status-set', 'agenda-add', 'agenda-drop', 'agenda-evict', 'agenda-set')),
|
|
target TEXT NOT NULL,
|
|
reason TEXT NOT NULL DEFAULT '',
|
|
prior TEXT NOT NULL DEFAULT ''
|
|
);
|
|
|
|
CREATE INDEX IF NOT EXISTS events_session ON events (session);
|