-- 创建用户喝水记录表
CREATE TABLE IF NOT EXISTS `t_user_water_history` (
  `id` BIGINT NOT NULL AUTO_INCREMENT,
  `user_id` VARCHAR(255) NOT NULL COMMENT '用户ID',
  `amount` INT NOT NULL COMMENT '喝水量（毫升）',
  `source` ENUM('manual', 'auto', 'other') NOT NULL DEFAULT 'manual' COMMENT '记录来源',
  `remark` VARCHAR(255) NULL COMMENT '备注',
  `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  INDEX `idx_user_id` (`user_id`),
  INDEX `idx_created_at` (`created_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='用户喝水记录表';

-- 为用户档案表添加喝水目标字段
ALTER TABLE `t_user_profile` 
ADD COLUMN `daily_water_goal` INT NULL COMMENT '每日喝水目标（毫升）' AFTER `activity_level`;