Skip to content

Commit

Permalink
Composite index on (shareid, user) for share state to enforce uniqueness
Browse files Browse the repository at this point in the history
  • Loading branch information
jessegeens committed Feb 3, 2025
1 parent 2bdd798 commit 9337420
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions share/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ type PublicLink struct {

type ShareState struct {
gorm.Model
ShareID uint `gorm:"foreignKey:ShareID;references:ID"` // Define the foreign key field
ShareID uint `gorm:"foreignKey:ShareID;references:ID;uniqueIndex:compositeindex"` // Define the foreign key field
Share Share // Define the association
// Can not be uid because of lw accs
User string
User string `gorm:"uniqueIndex:compositeindex"`
Synced bool
Hidden bool
Alias string
Expand Down

0 comments on commit 9337420

Please sign in to comment.