-- Runs the Passlabb page (the design built on Claude) on this server.
-- The page keeps its data as JSON documents addressed by paths like "bk/<uid>/b/<ref>"; they live here.
CREATE TABLE docs (
  path        text PRIMARY KEY,           -- full path, even number of segments
  coll        text NOT NULL,              -- parent collection path
  data        jsonb NOT NULL,
  version     int NOT NULL DEFAULT 1,
  updated_at  timestamptz NOT NULL DEFAULT now(),
  updated_by  text
);
CREATE INDEX docs_coll ON docs (coll);

-- The page itself. "Publish changes" in the page admin saves a new version; the newest one is served.
CREATE TABLE page_versions (
  id          serial PRIMARY KEY,
  html        text NOT NULL,
  created_at  timestamptz NOT NULL DEFAULT now(),
  created_by  text
);
