Skip to content

Commit

Permalink
Merge pull request #29 from Dhruv9449/v2
Browse files Browse the repository at this point in the history
feat: on delete cascade relationships
  • Loading branch information
Dhruv9449 authored Feb 1, 2024
2 parents f411fd4 + bf8b0fe commit bd6e9cc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions vitty-backend-api/internal/models/friends.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
type FriendRequest struct {
FromUsername string `gorm:"primaryKey"`
ToUsername string `gorm:"primaryKey"`
From User `gorm:"foreignKey:FromUsername;references:Username"`
To User `gorm:"foreignKey:ToUsername;references:Username"`
From User `gorm:"foreignKey:FromUsername;references:Username;constraint:OnDelete:CASCADE"`
To User `gorm:"foreignKey:ToUsername;references:Username;constraint:OnDelete:CASCADE"`
}

func (fr *FriendRequest) Accept() {
Expand Down
2 changes: 1 addition & 1 deletion vitty-backend-api/internal/models/timetable.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type Slot struct {
}

type Timetable struct {
User User `gorm:"foreignKey:UserUsername;references:Username"`
User User `gorm:"foreignKey:UserUsername;references:Username;constraint:OnDelete:CASCADE"`
UserUsername string `gorm:"primaryKey"`
Slots []Slot `gorm:"serializer:json"`
}
Expand Down

0 comments on commit bd6e9cc

Please sign in to comment.