-- 家人点赞（邀请码观看页点赞，按诊单+日期汇总，患者端可见）

CREATE TABLE IF NOT EXISTS `zyt_tcm_daily_family_like` (
    `id` int unsigned NOT NULL AUTO_INCREMENT,
    `diagnosis_id` int unsigned NOT NULL COMMENT '诊单ID',
    `like_date` date NOT NULL COMMENT '点赞日期（仅当日有效）',
    `invite_code` varchar(16) NOT NULL DEFAULT '' COMMENT '来源邀请码',
    `viewer_key` varchar(64) NOT NULL COMMENT '访客设备标识，防重复点赞',
    `nickname` varchar(16) NOT NULL DEFAULT '家人' COMMENT '显示称呼',
    `create_time` int unsigned NOT NULL DEFAULT 0,
    PRIMARY KEY (`id`),
    UNIQUE KEY `uk_day_viewer` (`diagnosis_id`, `like_date`, `viewer_key`),
    KEY `idx_diagnosis_date` (`diagnosis_id`, `like_date`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='日常记录家人点赞';
