-- 客商评分记录逻辑删除字段修复
-- 将历史默认值 -1 统一为正常未删除状态 0，避免评分记录被查询过滤。

ALTER TABLE `blade_customer_credit_score`
  MODIFY COLUMN `is_deleted` int NULL DEFAULT 0 COMMENT '是否已删除';

ALTER TABLE `blade_customer_credit_score_detail`
  MODIFY COLUMN `is_deleted` int NULL DEFAULT 0 COMMENT '是否已删除';

-- 修复历史记录：-1 并非逻辑删除标识，应作为未删除数据保留。
UPDATE `blade_customer_credit_score`
SET `is_deleted` = 0
WHERE `is_deleted` = -1;

UPDATE `blade_customer_credit_score_detail`
SET `is_deleted` = 0
WHERE `is_deleted` = -1;
