-- =============================================================================
-- 修复 quick_rules 表中 priority 为 NULL 的记录
-- 触发场景：routing_target 类型的初始化数据未指定 priority 列，
--          导致 Pydantic 序列化 QuickRuleResponse 时 ValidationError
-- =============================================================================

-- 1. 先查看受影响的记录
SELECT id, rule_type, category, keyword, priority
FROM quick_rules
WHERE priority IS NULL
ORDER BY id;

-- 2. 回填优先级
UPDATE quick_rules
SET priority = 0
WHERE priority IS NULL;

-- 3. 验证结果
SELECT COUNT(*) AS null_priority_count
FROM quick_rules
WHERE priority IS NULL;
