Setting Consents userid null upon deletion

This commit is contained in:
Alex
2025-05-14 18:25:53 +02:00
parent 242d37713d
commit 20a693a80c
3 changed files with 7 additions and 4 deletions

View File

@@ -16,7 +16,8 @@ type Consent struct {
LastName string `gorm:"not null" json:"last_name" binding:"safe_content"`
Email string `json:"email" binding:"email,safe_content"`
ConsentType string `gorm:"not null" json:"consent_type" binding:"safe_content"`
UserID uint `gorm:"not null" json:"user_id"`
UserID *uint `json:"user_id"`
User *User `gorm:"constraint:OnUpdate:CASCADE,OnDelete:SET NULL;"`
}
func (c *Consent) BeforeSave(tx *gorm.DB) (err error) {