Files
junhong_cmp_fiber/migrations/000019_fix_device_sim_binding_constraints.up.sql
huang ce0783f96e
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 5m30s
feat: 实现设备管理和设备导入功能,修复测试问题
主要变更:
- 实现设备管理模块(创建、查询、列表、更新状态、删除)
- 实现设备批量导入功能(CSV 解析、ICCID 绑定、异步任务处理)
- 添加设备-SIM 卡绑定约束(部分唯一索引防止并发问题)
- 修复 fee_rate 数据库字段类型(numeric -> bigint)
- 修复测试数据隔离问题(基于增量断言)
- 修复集成测试中间件顺序问题
- 清理无用测试文件(PersonalCustomer、Email 相关)
- 归档 enterprise-card-authorization 变更
2026-01-26 18:05:12 +08:00

19 lines
918 B
SQL
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
-- 修复设备-SIM卡绑定隐患
-- 1. 添加设备插槽唯一索引,防止同一插槽绑定多张卡
-- 2. 为导入任务表添加警告字段,支持部分成功反馈
-- 使用 CONCURRENTLY 避免锁表(注意:需要在事务外执行,此处仅作为参考)
-- 生产环境建议手动执行CREATE UNIQUE INDEX CONCURRENTLY idx_active_device_slot ...
CREATE UNIQUE INDEX IF NOT EXISTS idx_active_device_slot
ON tb_device_sim_binding (device_id, slot_position)
WHERE bind_status = 1 AND deleted_at IS NULL;
-- 为导入任务表添加警告字段
ALTER TABLE tb_device_import_task
ADD COLUMN IF NOT EXISTS warning_count INT NOT NULL DEFAULT 0,
ADD COLUMN IF NOT EXISTS warning_items JSONB;
-- 添加字段注释
COMMENT ON COLUMN tb_device_import_task.warning_count IS '警告数量(部分成功的设备)';
COMMENT ON COLUMN tb_device_import_task.warning_items IS '警告记录详情';