-- Administrator announcements shown as banners in the dashboard, optionally
-- scheduled with a start/end window.
CREATE TABLE IF NOT EXISTS `announcements` (
    `id`         BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
    `title`      VARCHAR(160)    NOT NULL,
    `body`       TEXT            NULL,
    `level`      VARCHAR(20)     NOT NULL DEFAULT 'info',  -- info/success/warning/danger
    `active`     TINYINT(1)      NOT NULL DEFAULT 1,
    `starts_at`  DATETIME        NULL,
    `ends_at`    DATETIME        NULL,
    `created_by` BIGINT UNSIGNED NULL,
    `created_at` DATETIME        NOT NULL DEFAULT CURRENT_TIMESTAMP,
    PRIMARY KEY (`id`),
    KEY `idx_ann_active` (`active`),
    CONSTRAINT `fk_ann_user` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
