fix: 单卡导入虚拟号改为可选,非空时保证全局唯一
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m26s
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m26s
This commit is contained in:
13
migrations/000108_iot_card_virtual_no_optional.down.sql
Normal file
13
migrations/000108_iot_card_virtual_no_optional.down.sql
Normal 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;
|
||||
Reference in New Issue
Block a user