-- 签到记录表
CREATE TABLE IF NOT EXISTS `checkin_record` (
  `id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `user_id` BIGINT NOT NULL COMMENT '用户ID',
  `checkin_date` DATE NOT NULL COMMENT '签到日期',
  `continuous_days` INT DEFAULT 0 COMMENT '当前连续签到天数',
  `total_days` INT DEFAULT 0 COMMENT '累计签到天数',
  `reward_received` INT DEFAULT 0 COMMENT '是否获得奖励 0-否 1-是',
  `reward_type` INT DEFAULT 0 COMMENT '奖励类型 0-无 1-1天VIP 2-3天VIP 3-7天VIP',
  `create_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `uk_user_date` (`user_id`, `checkin_date`),
  KEY `idx_user_id` (`user_id`),
  KEY `idx_checkin_date` (`checkin_date`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='签到记录表';

-- 插入测试数据（可选）
-- INSERT INTO `checkin_record` (`user_id`, `checkin_date`, `continuous_days`, `total_days`, `reward_received`, `reward_type`, `create_time`)
-- VALUES (1, '2025-10-10', 1, 1, 0, 0, '2025-10-10 09:00:00');

