-- summary_actions records the maintainer's act on a summary (watch/skip/save) —
-- the column that makes the Stage-0 headline metric ("acts on >=1 summary")
-- queryable (ui-spec.md §5, ADR-011). Per-user isolation: every row carries
-- user_id (dormant authz at Stage 0, single user). video_id is TEXT and not
-- FK-constrained, mirroring summaries' standalone (user_id, video_id) key.

CREATE TABLE summary_actions (
    id        UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    user_id   UUID NOT NULL,
    video_id  TEXT NOT NULL,
    action    TEXT NOT NULL,
    acted_at  TIMESTAMPTZ NOT NULL DEFAULT NOW(),
    CONSTRAINT summary_actions_action_check
        CHECK (action IN ('watched', 'skipped', 'saved')),
    CONSTRAINT summary_actions_user_video_action_unique
        UNIQUE (user_id, video_id, action)
);

CREATE INDEX idx_summary_actions_user_video ON summary_actions(user_id, video_id);
