Skip to content

Commit 5a2749e

Browse files
committed
replaced composite PK with PK on Id, because the composite would find duplicates as it ignored deleted_at
1 parent 642fc60 commit 5a2749e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

share/model.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ type ShareID struct {
4545
type BaseModel struct {
4646
// Id has to be called Id and not ID, otherwise the foreign key will not work
4747
// ID is a special field in GORM, which it uses as the default Primary Key
48-
Id uint `gorm:"uniqueIndex;not null"`
48+
Id uint `gorm:"primaryKey;not null;autoIncrement:false"`
4949
ShareId ShareID `gorm:"foreignKey:Id;references:ID;constraint:OnDelete:CASCADE"` //;references:ID
5050
CreatedAt time.Time
5151
UpdatedAt time.Time
@@ -62,23 +62,23 @@ type ProtoShare struct {
6262
UIDInitiator string `gorm:"size:64;index"`
6363
ItemType ItemType `gorm:"size:16;index"` // file | folder | reference | symlink
6464
InitialPath string
65-
Inode string `gorm:"primaryKey;size:32;index"`
66-
Instance string `gorm:"primaryKey;size:32;index"`
65+
Inode string `gorm:"size:32;index"`
66+
Instance string `gorm:"size:32;index"`
6767
Permissions uint8
6868
Orphan bool
6969
Expiration datatypes.NullTime
7070
}
7171

7272
type Share struct {
7373
ProtoShare
74-
ShareWith string `gorm:"primaryKey;size:255;index:i_share_with"` // 255 because this can be a lw account, which are mapped from email addresses / ...
74+
ShareWith string `gorm:"size:255;index:i_share_with"` // 255 because this can be a lw account, which are mapped from email addresses / ...
7575
SharedWithIsGroup bool
7676
Description string `gorm:"size:1024"`
7777
}
7878

7979
type PublicLink struct {
8080
ProtoShare
81-
Token string `gorm:"primaryKey;index:i_token"`
81+
Token string `gorm:"uniqueIndex:i_token;size:16"`
8282
Quicklink bool
8383
NotifyUploads bool
8484
NotifyUploadsExtraRecipients string

0 commit comments

Comments
 (0)