-- 309_eid_weekly_recap_table.sql — 303_eid_weekly_recap.sql 분리본 (single-statement). asyncpg 러너가 prepared statement 로 처리해 multi-statement 거부 → 1 stmt/파일. 내용 불변.

CREATE TABLE IF NOT EXISTS eid_weekly_recap (
    id                   BIGSERIAL   PRIMARY KEY,
    user_id              BIGINT      NOT NULL REFERENCES users(id) ON DELETE CASCADE,
    period_start         DATE        NOT NULL,
    period_end           DATE        NOT NULL,
    recap                JSONB       NOT NULL,   -- {activity_summary, open_action_items:[event_id], recurring_topics}
    trend_label          VARCHAR(20),
    status               VARCHAR(20) NOT NULL DEFAULT 'active',  -- 'active' | 'disputed'
    supersedes_id        BIGINT      REFERENCES eid_weekly_recap(id) ON DELETE SET NULL,
    actor                VARCHAR(20) NOT NULL,   -- 스탬프 = 'eid'
    source_generated_at  TIMESTAMPTZ NOT NULL,   -- 스탬프
    created_at           TIMESTAMPTZ NOT NULL DEFAULT now()
);
