-- Additive only: existing tables, rows, and columns are untouched.
-- Finished-roast .alog uploads: the raw file is retained verbatim (original_content) so the
-- user can always download their own backup; parsed is the parseAlog() output the UI renders;
-- evaluation is the Pi agent's review, written asynchronously after upload.
CREATE TABLE actual_roasts (
  id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
  user_id uuid NOT NULL REFERENCES users(id) ON DELETE CASCADE,
  roast_plan_id uuid REFERENCES roast_plans(id) ON DELETE SET NULL,
  filename text NOT NULL,
  original_content text NOT NULL,
  parsed jsonb NOT NULL,
  evaluation jsonb,
  evaluation_status text NOT NULL DEFAULT 'pending',
  evaluation_error text,
  created_at timestamptz NOT NULL DEFAULT now(),
  updated_at timestamptz NOT NULL DEFAULT now()
);
CREATE INDEX actual_roasts_user ON actual_roasts(user_id, created_at DESC);
CREATE INDEX actual_roasts_plan ON actual_roasts(roast_plan_id);
