change function and gorm tag

This commit is contained in:
Adrian Zürcher
2025-11-20 18:00:12 +01:00
parent 1d203d1d2f
commit f28a3edbcf
3 changed files with 12 additions and 6 deletions

View File

@@ -5,5 +5,5 @@ type Event struct {
Name string `gorm:"column:name" json:"name"`
Date string `gorm:"column:date" json:"date"`
Day string `gorm:"column:day" json:"day"`
Attendees []*Member `gorm:"many2many:member_events;" json:"attendees"`
Attendees []*Member `gorm:"many2many:member_events;constraint:OnDelete:CASCADE;" json:"attendees"`
}

View File

@@ -21,9 +21,9 @@ type Member struct {
FirstVisit string `gorm:"column:firstVisit" json:"firstVisit,omitempty"`
LastVisit string `gorm:"column:lastVisit" json:"lastVisit,omitempty"`
GroupId *int `json:"GroupId,omitempty"`
Group *Group `gorm:"foreignKey:GroupId" json:"group,omitempty"`
Group *Group `gorm:"foreignKey:GroupId;constraint:OnDelete:CASCADE;"json:"group,omitempty"`
ResponsibleId *int `json:"ResponsibleId,omitempty"`
Responsible *Member `gorm:"foreignKey:ResponsibleId" json:"responsible,omitempty"`
Responsible *Member `gorm:"foreignKey:ResponsibleId;constraint:OnDelete:CASCADE;" json:"responsible,omitempty"`
Comment string `gorm:"column:comment" json:"comment,omitempty"`
Events []*Event `gorm:"many2many:member_events;" `
}