-- ============================================================
-- AIoT 离岗检测算法参数更新迁移脚本
-- 功能：添加 leave_countdown_sec（离岗倒计时）参数
-- 执行时间：2026-02-12
-- ============================================================

-- 更新 leave_post 算法的 param_schema
-- 添加 leave_countdown_sec (默认300秒 = 5分钟)
-- 修正 confirm_leave_sec 默认值从10秒改为30秒
-- 修正 cooldown_sec 默认值从300秒改为600秒
UPDATE wvp_ai_algorithm
SET param_schema = '{"confirm_on_duty_sec":{"type":"int","default":10,"min":1},"confirm_leave_sec":{"type":"int","default":30,"min":1},"leave_countdown_sec":{"type":"int","default":300,"min":0},"cooldown_sec":{"type":"int","default":600,"min":0},"working_hours":{"type":"list","default":[]}}',
    update_time = NOW()
WHERE algo_code = 'leave_post';

-- 验证更新结果
SELECT algo_code, algo_name, param_schema, update_time
FROM wvp_ai_algorithm
WHERE algo_code = 'leave_post';
