From b922d986d6783ce28d00ca948024dee44a11f29e Mon Sep 17 00:00:00 2001 From: Zahar Izmailov Date: Mon, 3 Feb 2025 15:36:03 +0300 Subject: Improved database model migration and added indexing (#2655) --- database/model/model.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'database/model') diff --git a/database/model/model.go b/database/model/model.go index e9d1836f..915cae0b 100644 --- a/database/model/model.go +++ b/database/model/model.go @@ -29,14 +29,14 @@ type User struct { type Inbound struct { Id int `json:"id" form:"id" gorm:"primaryKey;autoIncrement"` - UserId int `json:"-"` + UserId int `json:"-" gorm:"index"` Up int64 `json:"up" form:"up"` Down int64 `json:"down" form:"down"` Total int64 `json:"total" form:"total"` Remark string `json:"remark" form:"remark"` Enable bool `json:"enable" form:"enable"` ExpiryTime int64 `json:"expiryTime" form:"expiryTime"` - ClientStats []xray.ClientTraffic `gorm:"foreignKey:InboundId;references:Id" json:"clientStats" form:"clientStats"` + ClientStats []xray.ClientTraffic `gorm:"foreignKey:InboundId;references:Id;constraint:OnDelete:CASCADE" json:"clientStats"` // config part Listen string `json:"listen" form:"listen"` -- cgit v1.2.3