-- 更新旧数据，为新字段设置默认值
-- 这样可以确保所有记录都有完整的数据

UPDATE `zyt_tcm_prescription` 
SET 
    `usage_days` = COALESCE(`usage_days`, 7),
    `usage_time` = COALESCE(`usage_time`, '饭前'),
    `usage_way` = COALESCE(`usage_way`, '温水送服'),
    `dietary_taboo` = COALESCE(`dietary_taboo`, ''),
    `usage_notes` = COALESCE(`usage_notes`, ''),
    `is_shared` = COALESCE(`is_shared`, 0)
WHERE `delete_time` IS NULL;

-- 查看更新结果
SELECT id, sn, prescription_name, usage_days, usage_time, usage_way, dietary_taboo, usage_notes, is_shared 
FROM `zyt_tcm_prescription` 
WHERE `delete_time` IS NULL
LIMIT 5;
