-- Version 23 to 24: two new tables for the automatic judge's review of rules for every project, what
-- it decided and the texts it failed on. Nothing else changes.
-- Run on its own, with nothing else holding the archive:
-- sqlite3 ~/.ctx/ctx.sqlite < schema/migrate/24-up.sql (or: ctx does this itself when it opens the archive)
BEGIN IMMEDIATE;
-- What the automatic judge (ctx rules auto) decided about the scope of a rule for every project.
-- id is what ctx rules undo sN names. rule_hash is the rule's text as judged, so a text is judged
-- once; a rule whose text changes is judged again. global: kept for every project; project: moved
-- to project; note: retired as a status note; left: the answer named no project ctx knows, or the
-- rule was too long to send whole, and nothing changed. prior_reason is the reason line the rule
-- had before a note retired it, so an undo puts it back as it was.
CREATE TABLE IF NOT EXISTS ctx_scope_judged(
id INTEGER PRIMARY KEY,
key TEXT NOT NULL,
rule_hash TEXT NOT NULL,
decision TEXT NOT NULL CHECK (decision IN ('global', 'project', 'note', 'left')),
project TEXT, -- for project: where it went
prior_reason TEXT, -- for note
title TEXT NOT NULL,
why TEXT NOT NULL,
model TEXT NOT NULL,
at TEXT NOT NULL,
undone INTEGER NOT NULL DEFAULT 0
) STRICT;
CREATE INDEX IF NOT EXISTS ctx_scope_judged_key ON ctx_scope_judged(key, rule_hash);
-- Rule texts the scope judge failed on (a failed command, or an answer it could not read). At two,
-- the text is not sent again; a new text starts again at none.
CREATE TABLE IF NOT EXISTS ctx_scope_fail(
key TEXT NOT NULL,
rule_hash TEXT NOT NULL,
fails INTEGER NOT NULL,
PRIMARY KEY (key, rule_hash)
) STRICT, WITHOUT ROWID;
PRAGMA user_version = 24;
COMMIT;