-- Lives in the dedicated `news` database (NOT `outages`). Migrated out
-- of `outages` DB on 2026-05-15 so dedupe-log state is separate from
-- operational outage data.
--   USE news;
--   then the CREATE TABLE below

CREATE TABLE IF NOT EXISTS outage_news_log (
    id           INT UNSIGNED NOT NULL AUTO_INCREMENT,
    event_type   VARCHAR(40)  NOT NULL,
    event_key    VARCHAR(120) NOT NULL,
    unit_name    VARCHAR(128) NULL,
    topic_id     INT UNSIGNED NULL,
    msg_id       INT UNSIGNED NULL,
    posted_at    DATETIME     NOT NULL,
    status       ENUM('posted','updated','error','dry_run') NOT NULL DEFAULT 'posted',
    payload_json LONGTEXT     NULL,
    error_msg    TEXT         NULL,
    PRIMARY KEY (id),
    UNIQUE KEY uk_event (event_type, event_key),
    KEY idx_unit (unit_name),
    KEY idx_posted (posted_at)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
SHOW CREATE TABLE outage_news_log\G
