-- 创建推送提醒历史记录表
CREATE TABLE `t_push_reminder_history` (
  `id` char(36) NOT NULL DEFAULT (UUID()),
  `user_id` varchar(64) DEFAULT NULL COMMENT '用户ID，可能为空',
  `device_token` varchar(255) NOT NULL COMMENT '设备推送令牌',
  `reminder_type` enum('challenge_encouragement','challenge_invitation','general_invitation') NOT NULL COMMENT '提醒类型',
  `last_sent_at` datetime NOT NULL COMMENT '最后发送时间',
  `sent_count` int NOT NULL DEFAULT '0' COMMENT '发送次数',
  `next_available_at` datetime DEFAULT NULL COMMENT '下次可发送时间',
  `is_active` tinyint(1) NOT NULL DEFAULT '1' COMMENT '是否激活',
  `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  KEY `idx_user_device_type` (`user_id`,`device_token`,`reminder_type`),
  KEY `idx_last_sent_at` (`last_sent_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='推送提醒历史记录表';