-- Morning Briefing 자식 (topic_rank 순, UNIQUE briefing_id + topic_rank).
-- country_perspectives/divergences/convergences/key_quotes JSONB (cap 은 application).
-- historical_* 3 컬럼은 BRIEFING_HISTORICAL_ENABLED on 시만 채움 (nullable).
CREATE TABLE briefing_topics (
    id                     BIGSERIAL PRIMARY KEY,
    briefing_id            BIGINT NOT NULL REFERENCES morning_briefings(id) ON DELETE CASCADE,
    topic_rank             INTEGER NOT NULL,
    topic_label            VARCHAR(120) NOT NULL,
    headline               TEXT NOT NULL,
    country_perspectives   JSONB NOT NULL DEFAULT '[]',
    divergences            JSONB NOT NULL DEFAULT '[]',
    convergences           JSONB NOT NULL DEFAULT '[]',
    key_quotes             JSONB NOT NULL DEFAULT '[]',
    historical_article_ids JSONB,
    historical_context     TEXT,
    historical_window_days INTEGER,
    cluster_members        JSONB NOT NULL DEFAULT '[]',
    article_count          INTEGER NOT NULL,
    country_count          INTEGER NOT NULL,
    importance_score       DOUBLE PRECISION NOT NULL,
    raw_weight_sum         DOUBLE PRECISION NOT NULL,
    llm_model              VARCHAR(100),
    llm_fallback_used      BOOLEAN NOT NULL DEFAULT FALSE,
    created_at             TIMESTAMPTZ NOT NULL DEFAULT NOW(),
    UNIQUE (briefing_id, topic_rank)
)
