Explorar o código

fix(postgres): clear client_traffics before deleting inbound

DelInbound removed the client_inbounds join rows but never deleted the
inbound's client_traffics, so Postgres rejected the inbound delete with
fk_inbounds_client_stats (SQLSTATE 23503). SQLite never enforced the FK
so this went unnoticed. Delete client_traffics first, matching the order
already used in the sync path.
MHSanaei hai 11 horas
pai
achega
c20ee00fa3
Modificáronse 1 ficheiros con 4 adicións e 0 borrados
  1. 4 0
      web/service/inbound.go

+ 4 - 0
web/service/inbound.go

@@ -610,6 +610,10 @@ func (s *InboundService) DelInbound(id int) (bool, error) {
 		logger.Debug("DelInbound: inbound not found, id:", id)
 	}
 
+	if err := db.Where("inbound_id = ?", id).Delete(&xray.ClientTraffic{}).Error; err != nil {
+		return false, err
+	}
+
 	if err := s.clientService.DetachInbound(db, id); err != nil {
 		return false, err
 	}