From c20ee00fa3f7c4893dc849b8b421030cc23df78a Mon Sep 17 00:00:00 2001 From: MHSanaei Date: Sun, 31 May 2026 19:48:19 +0200 Subject: [PATCH] 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. --- web/service/inbound.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/web/service/inbound.go b/web/service/inbound.go index f75868cb..57157044 100644 --- a/web/service/inbound.go +++ b/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 }