Skip to content

Commit

Permalink
fix: remove codeHostings when deleting publishers
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bfabio committed Jul 20, 2024
1 parent f8bda35 commit 69b1604
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion internal/models/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type Publisher struct {
ID string `json:"id" gorm:"primaryKey"`
Email *string `json:"email,omitempty"`
Description string `json:"description" gorm:"uniqueIndex;not null"`
CodeHosting []CodeHosting `json:"codeHosting" gorm:"constraint:OnUpdate:CASCADE,OnDelete:SET NULL;unique"`
CodeHosting []CodeHosting `json:"codeHosting" gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;unique"`
Active *bool `json:"active" gorm:"default:true;not null"`
AlternativeID *string `json:"alternativeId,omitempty" gorm:"uniqueIndex"`
CreatedAt time.Time `json:"createdAt" gorm:"index"`
Expand Down

0 comments on commit 69b1604

Please sign in to comment.