diff options
Diffstat (limited to 'schema.sql')
| -rw-r--r-- | schema.sql | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/schema.sql b/schema.sql index 1d38f7a..d7dcdd3 100644 --- a/schema.sql +++ b/schema.sql @@ -1,4 +1,4 @@ --- ai-memory schema, version 6. +-- ai-memory schema, version 7. -- -- commits : one row per git commit, derived from `git log' by `sync'. -- symbols : one declared identifier per row (proc, fn, type, const, var). @@ -6,7 +6,8 @@ -- reasoning: appends the *why*; may exist before the commit does, in which -- case commit_hash is NULL until `attach' sets it. `basis' records -- how the entry was established; `supersedes' points at the entry a --- correction replaces, so nothing is ever overwritten. +-- correction replaces, so nothing is ever overwritten. `uuid' is +-- the stable identity of an entry; `id' is only its local number. create table if not exists commits ( hash text primary key, @@ -32,6 +33,10 @@ create table if not exists touches ( create table if not exists reasoning ( id integer primary key, + -- Stable identity across stores and machines. `id' is allocated locally and + -- is reassigned when a dump is restored, so a reference that must survive a + -- merge (supersedes_uuid, a dump, another machine) uses this instead. + uuid text, commit_hash text references commits(hash) on delete cascade, session_id text, step integer, @@ -42,6 +47,10 @@ create table if not exists reasoning ( basis text, -- A correction points at the entry it replaces instead of editing it. supersedes integer references reasoning(id), + -- The same link in stable form. `supersedes' is the local id used by + -- queries; this is what a dump carries, so a restored or merged store can + -- rebuild the local link without renumbering anything by hand. + supersedes_uuid text, -- One line: the claim itself, written when the context is in hand. Listings -- show this by default; the body is the long form. gist text, @@ -54,6 +63,8 @@ create table if not exists reasoning ( unique (session_id, step, kind) ); +create unique index if not exists reasoning_uuid_idx on reasoning (uuid); + create index if not exists reasoning_superseded_idx on reasoning (supersedes); create index if not exists touch_symbol_idx on touches (symbol_id); @@ -90,4 +101,4 @@ create trigger if not exists reasoning_after_update after update on reasoning be insert into reasoning_fts (rowid, body) values (new.id, new.body); end; -pragma user_version = 6; +pragma user_version = 7; |
