diff --git a/inventory-backend/app/services/bom_service.py b/inventory-backend/app/services/bom_service.py index 9e3bac1..616c218 100644 --- a/inventory-backend/app/services/bom_service.py +++ b/inventory-backend/app/services/bom_service.py @@ -194,6 +194,9 @@ class BomService: for rec in old_records: db.session.delete(rec) + # 【核心修复】:强制立即执行 DELETE 语句,为后续的 INSERT 腾出唯一键空间 + db.session.flush() + for child in children: bom = BomTable( bom_no=bom_no,