fix: 单卡导入虚拟号改为可选,非空时保证全局唯一
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m26s

This commit is contained in:
2026-04-08 10:45:23 +08:00
parent 38ef73fd7f
commit 14a8ea5a2c
5 changed files with 35 additions and 31 deletions

View File

@@ -0,0 +1,13 @@
-- 回滚:将 tb_iot_card.virtual_no 恢复为 NOT NULL并重建无条件唯一索引
-- 清理空值记录(如有)
DELETE FROM tb_iot_card WHERE virtual_no IS NULL OR virtual_no = '';
-- 删除条件唯一索引
DROP INDEX IF EXISTS idx_iot_card_virtual_no;
-- 将 virtual_no 列改为 NOT NULL
ALTER TABLE tb_iot_card ALTER COLUMN virtual_no SET NOT NULL;
-- 重建无条件唯一索引
CREATE UNIQUE INDEX idx_iot_card_virtual_no ON tb_iot_card(virtual_no) WHERE deleted_at IS NULL;