Mhamdans17 commited on
Commit
17e3823
·
1 Parent(s): ea73154

fix: add missing constraint cascades for wallet and points

Browse files
Files changed (1) hide show
  1. models/models.go +4 -0
models/models.go CHANGED
@@ -36,6 +36,9 @@ type Company struct {
36
  Products []Product `gorm:"foreignKey:CompanyID;constraint:OnDelete:CASCADE" json:"-"`
37
  Orders []Order `gorm:"foreignKey:CompanyID;constraint:OnDelete:CASCADE" json:"-"`
38
  Members []Member `gorm:"foreignKey:CompanyID;constraint:OnDelete:CASCADE" json:"-"`
 
 
 
39
  }
40
 
41
  type PointRule struct {
@@ -61,6 +64,7 @@ type Member struct {
61
  Company *Company `gorm:"foreignKey:CompanyID" json:"company,omitempty"`
62
  Branch *Branch `gorm:"foreignKey:BranchID;constraint:OnDelete:SET NULL;" json:"branch,omitempty"`
63
  CreatedBy *User `gorm:"foreignKey:CreatedByID;constraint:OnDelete:SET NULL;" json:"created_by,omitempty"`
 
64
  }
65
 
66
  type PointHistory struct {
 
36
  Products []Product `gorm:"foreignKey:CompanyID;constraint:OnDelete:CASCADE" json:"-"`
37
  Orders []Order `gorm:"foreignKey:CompanyID;constraint:OnDelete:CASCADE" json:"-"`
38
  Members []Member `gorm:"foreignKey:CompanyID;constraint:OnDelete:CASCADE" json:"-"`
39
+ PointHistories []PointHistory `gorm:"foreignKey:CompanyID;constraint:OnDelete:CASCADE" json:"-"`
40
+ WalletTransactions []WalletTransaction `gorm:"foreignKey:CompanyID;constraint:OnDelete:CASCADE" json:"-"`
41
+ TopupRequests []TopupRequest `gorm:"foreignKey:CompanyID;constraint:OnDelete:CASCADE" json:"-"`
42
  }
43
 
44
  type PointRule struct {
 
64
  Company *Company `gorm:"foreignKey:CompanyID" json:"company,omitempty"`
65
  Branch *Branch `gorm:"foreignKey:BranchID;constraint:OnDelete:SET NULL;" json:"branch,omitempty"`
66
  CreatedBy *User `gorm:"foreignKey:CreatedByID;constraint:OnDelete:SET NULL;" json:"created_by,omitempty"`
67
+ PointHistories []PointHistory `gorm:"foreignKey:MemberID;constraint:OnDelete:CASCADE" json:"-"`
68
  }
69
 
70
  type PointHistory struct {