-- Morning Briefing 부모 테이블 (일일 1행, briefing_date UNIQUE).
-- asyncpg prepared statement 가 multi-statement 불허라 인덱스 + 자식 테이블은 별 migration.
CREATE TABLE morning_briefings (
    id                BIGSERIAL PRIMARY KEY,
    briefing_date     DATE NOT NULL,
    window_start      TIMESTAMPTZ NOT NULL,
    window_end        TIMESTAMPTZ NOT NULL,
    decay_lambda      DOUBLE PRECISION NOT NULL,
    total_articles    INTEGER NOT NULL DEFAULT 0,
    total_countries   INTEGER NOT NULL DEFAULT 0,
    total_topics      INTEGER NOT NULL DEFAULT 0,
    generation_ms     INTEGER,
    llm_calls         INTEGER NOT NULL DEFAULT 0,
    llm_failures      INTEGER NOT NULL DEFAULT 0,
    status            VARCHAR(20) NOT NULL DEFAULT 'success',
    headline_oneliner TEXT,
    created_at        TIMESTAMPTZ NOT NULL DEFAULT NOW(),
    UNIQUE (briefing_date)
)
