From 3dfc5b8a9633cc58d4044731e8b0d898960223e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Miserey?= Date: Mon, 8 May 2023 01:29:49 +0200 Subject: [PATCH] specify foreignKey --- models/instance.go | 2 +- models/relationship.go | 2 +- models/status.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/models/instance.go b/models/instance.go index 512e7a3..29eccad 100644 --- a/models/instance.go +++ b/models/instance.go @@ -18,7 +18,7 @@ type Instance struct { UpdatedAt time.Time Domain string `gorm:"size:64;uniqueIndex"` AdminID *snowflake.ID - Admin *Account `gorm:"constraint:OnDelete:CASCADE;<-:create;"` // the admin account for this instance + Admin *Account `gorm:"foreignKey:AdminID;constraint:OnDelete:CASCADE;<-:create;"` // the admin account for this instance SourceURL string Title string `gorm:"size:64"` ShortDescription string diff --git a/models/relationship.go b/models/relationship.go index 7a5f8d0..916b87e 100644 --- a/models/relationship.go +++ b/models/relationship.go @@ -13,7 +13,7 @@ type Relationship struct { ActorID snowflake.ID `gorm:"primarykey;autoIncrement:false"` Actor *Actor `gorm:"constraint:OnDelete:CASCADE;<-:false;"` TargetID snowflake.ID `gorm:"primarykey;autoIncrement:false"` - Target *Actor `gorm:"constraint:OnDelete:CASCADE;<-:false;"` + Target *Actor `gorm:"foreignKey:TargetID;constraint:OnDelete:CASCADE;<-:false;"` Muting bool `gorm:"not null;default:false"` Blocking bool `gorm:"not null;default:false"` BlockedBy bool `gorm:"not null;default:false"` diff --git a/models/status.go b/models/status.go index 2e2deea..76506dc 100644 --- a/models/status.go +++ b/models/status.go @@ -32,7 +32,7 @@ type Status struct { ReblogsCount int `gorm:"not null;default:0"` FavouritesCount int `gorm:"not null;default:0"` ReblogID *snowflake.ID - Reblog *Status `gorm:"constraint:OnDelete:CASCADE;<-:false;"` // don't update reblog on status update + Reblog *Status `gorm:"foreignKey:ReblogID;constraint:OnDelete:CASCADE;<-:false;"` // don't update reblog on status update Reaction *Reaction `gorm:"constraint:OnDelete:CASCADE;<-:false;"` // don't update reaction on status update Attachments []*StatusAttachment `gorm:"constraint:OnDelete:CASCADE;"` Mentions []StatusMention `gorm:"constraint:OnDelete:CASCADE;"`