-- Highlights + word-anchored notes on transcripts (Otter Wave 1).
-- One table: kind='highlight' marks a span as important; kind='note' adds body
-- text at the anchor. Anchor = viewer segment index + word span within it
-- (meeting_words indices); quote + start_ms are the durable fallback if the
-- segment text is ever edited. w_start/w_end = -1 anchors the whole segment.
-- Live PG < 9.5: plain CREATE INDEX. Also folded into 2026_07_13_meetings_combined.sql.

CREATE TABLE IF NOT EXISTS meeting_marks (
    id         varchar(32)  NOT NULL PRIMARY KEY,
    meeting_id varchar(32)  NOT NULL,
    company    varchar(32)  NOT NULL,
    kind       varchar(12)  NOT NULL DEFAULT 'highlight',   -- highlight | note
    seg_index  integer      NOT NULL,
    w_start    integer      NOT NULL DEFAULT -1,
    w_end      integer      NOT NULL DEFAULT -1,
    quote      varchar(400),
    start_ms   integer,
    body       text,
    created_by varchar(32),
    created    timestamp    NOT NULL DEFAULT now()
);

CREATE INDEX idx_mmk_meeting ON meeting_marks (meeting_id);
