-- Meetings PR2: live insights — structured, per-item rows (NOT text blobs) because
-- the end goal is action items becoming real Scapetime assignments (status flips
-- open -> converted). Claude refresh loop rewrites 'open' rows each pass; dismissed
-- rows persist and are fed back as "do not resurface".
-- Live PG < 9.5: plain CREATE INDEX, no ON CONFLICT.

CREATE TABLE IF NOT EXISTS meeting_insights (
    id               varchar(32)  NOT NULL PRIMARY KEY,
    meeting_id       varchar(32)  NOT NULL,
    company          varchar(32)  NOT NULL,
    kind             varchar(16)  NOT NULL,            -- action | decision | question
    content          text         NOT NULL,
    owner_name       varchar(128),                     -- speaker name as heard ('' if none)
    owner_user_id    varchar(32),                      -- future: linked Scapetime user
    source_offset_ms integer,                          -- where in the meeting it surfaced
    status           varchar(16)  NOT NULL DEFAULT 'open',  -- open | dismissed | converted
    created          timestamp    NOT NULL DEFAULT now(),
    updated          timestamp
);

CREATE INDEX idx_meeting_insights_meeting ON meeting_insights (meeting_id);
