Skip to content
context Artifact [90c9e611f5]
Login

Artifact [90c9e611f5]

Artifact 90c9e611f565f59766c75eb06b319378ef1ba4de53f8d76a8adf6053b24cc2d9:


-- Version 27 to 28: the review ledger, what reviewers returned, read from their reports by the
-- hourly scan, and how far each transcript has been read. Nothing else changes.
-- Run on its own, with nothing else holding the archive:
--   sqlite3 ~/.ctx/ctx.sqlite < schema/migrate/28-up.sql   (or: ctx does this itself when it opens the archive)

BEGIN IMMEDIATE;
CREATE TABLE IF NOT EXISTS ctx_review(
  id       INTEGER PRIMARY KEY,
  harness  TEXT NOT NULL,
  session  TEXT NOT NULL,      -- the reviewer's, as ctx_usage names it
  parent   TEXT NOT NULL,      -- the session that started it
  turn     INTEGER NOT NULL,   -- which prompt of the reviewer's transcript this answers, from 0
  folder   TEXT NOT NULL,      -- the transcript folder, for ctx exclude
  project  TEXT NOT NULL,
  checkin  TEXT,
  round    INTEGER NOT NULL,
  verdict  TEXT NOT NULL CHECK (verdict IN ('APPROVE', 'APPROVE_WITH_NITS', 'REQUEST_CHANGES')),
  form     TEXT NOT NULL CHECK (form IN ('full', 'verdict')),
  blocking INTEGER,
  nits     INTEGER,
  landed   INTEGER NOT NULL DEFAULT 0 CHECK (landed IN (0, 1)),
  at       TEXT NOT NULL,
  UNIQUE (harness, session, parent, turn)
) STRICT;
CREATE INDEX IF NOT EXISTS ctx_review_parent ON ctx_review(parent);

CREATE TABLE IF NOT EXISTS ctx_review_finding(
  review    INTEGER NOT NULL REFERENCES ctx_review(id) ON DELETE CASCADE,
  n         INTEGER NOT NULL,
  label     TEXT NOT NULL CHECK (label IN ('blocking', 'nit')),
  path      TEXT NOT NULL,
  line      INTEGER,
  class     TEXT NOT NULL,
  text      TEXT NOT NULL,
  confirmed TEXT,
  PRIMARY KEY (review, n)
) STRICT, WITHOUT ROWID;

CREATE TABLE IF NOT EXISTS ctx_review_escape(
  id       INTEGER PRIMARY KEY,
  project  TEXT NOT NULL,
  checkin  TEXT NOT NULL,
  ticket   TEXT,
  reviewed INTEGER NOT NULL CHECK (reviewed IN (0, 1)),
  at       TEXT NOT NULL
) STRICT;

CREATE TABLE IF NOT EXISTS ctx_review_read(
  path   TEXT PRIMARY KEY,
  offset INTEGER NOT NULL,
  turn   INTEGER NOT NULL,
  state  TEXT
) STRICT, WITHOUT ROWID;

PRAGMA user_version = 28;
COMMIT;