Skip to content

Commit 5fb2c69

Browse files
authored
fix: remove codeHostings when deleting publishers (#250)
Remove the associated codeHostings when using DELETE on a publisher. Code hostings are mapped 1-to-1 with a publisher, so they they're part of the resource. Not deleting them means we'd have dangling code hosting with no publisher, invisible to the API, and that can't be associated to a publisher anymore.
1 parent 3affed1 commit 5fb2c69

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

internal/models/models.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ type Publisher struct {
3535
ID string `json:"id" gorm:"primaryKey"`
3636
Email *string `json:"email,omitempty"`
3737
Description string `json:"description" gorm:"uniqueIndex;not null"`
38-
CodeHosting []CodeHosting `json:"codeHosting" gorm:"constraint:OnUpdate:CASCADE,OnDelete:SET NULL;unique"`
38+
CodeHosting []CodeHosting `json:"codeHosting" gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;unique"`
3939
Active *bool `json:"active" gorm:"default:true;not null"`
4040
AlternativeID *string `json:"alternativeId,omitempty" gorm:"uniqueIndex"`
4141
CreatedAt time.Time `json:"createdAt" gorm:"index"`

0 commit comments

Comments
 (0)