-- 系统公告表
CREATE TABLE `announcements` (
  `id` INT AUTO_INCREMENT PRIMARY KEY,
  `title` VARCHAR(128) NOT NULL,
  `content` TEXT NOT NULL,
  `publisher_id` INT NOT NULL,
  `is_top` TINYINT DEFAULT 0,       -- 是否置顶
  `status` TINYINT DEFAULT 1,       -- 1有效 0撤回/禁用
  `created_at` DATETIME NOT NULL,
  `updated_at` DATETIME NOT NULL,
  FOREIGN KEY (`publisher_id`) REFERENCES `users`(`id`)
);

-- 用户消息通知表
CREATE TABLE `notifications` (
  `id` INT AUTO_INCREMENT PRIMARY KEY,
  `user_id` INT NOT NULL,
  `title` VARCHAR(128) NOT NULL,
  `content` TEXT NOT NULL,
  `type` VARCHAR(32) NOT NULL,        -- 消息类型
  `status` TINYINT DEFAULT 0,         -- 0未读 1已读
  `sender_id` INT,                    -- 发送人（系统消息可为NULL或0）
  `created_at` DATETIME NOT NULL,
  `read_at` DATETIME DEFAULT NULL,
  FOREIGN KEY (`user_id`) REFERENCES `users`(`id`),
  FOREIGN KEY (`sender_id`) REFERENCES `users`(`id`)
);

