Skip to content

Commit

Permalink
fix: fix bug that the files associated with records still exist after…
Browse files Browse the repository at this point in the history
… deleting mysql and ftp records
  • Loading branch information
Li4n0 committed Nov 16, 2022
1 parent 48f55c5 commit 5e80591
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion internal/file/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

type File struct {
ID uint `gorm:"primarykey" form:"id" json:"id"`
RecordID uint `gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;" json:"-"`
RecordID uint `json:"-"`
Name string `json:"name"`
Content []byte `json:"-"`
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/ftp/record.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type Record struct {
Path string `form:"path" json:"path"`
Method Method `form:"method" json:"method"`
Status Status `form:"status" json:"status"`
File *file.FTPFile `form:"file" json:"file" notice:"-"`
File *file.FTPFile `gorm:"foreignKey:RecordID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;" form:"file" json:"file" notice:"-"`
Rule Rule `gorm:"foreignKey:RuleName;references:Name;constraint:OnUpdate:CASCADE,OnDelete:SET NULL;" form:"-" json:"-" notice:"-"`
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/mysql/record.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type Record struct {
Schema string `gorm:"index" form:"schema" json:"schema" notice:"schema"`
ClientOS string `gorm:"index" form:"client_os" json:"client_os" notice:"client_os"`
LoadLocalData bool `gorm:"index" form:"load_local_data" json:"load_local_data" notice:"load_local_data"`
Files []file.MySQLFile `form:"-" json:"files" notice:"-"`
Files []file.MySQLFile `gorm:"foreignKey:RecordID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;" form:"-" json:"files" notice:"-" `
Rule Rule `gorm:"foreignKey:RuleName;references:Name;constraint:OnUpdate:CASCADE,OnDelete:SET NULL;" form:"-" json:"-" notice:"-"`
}

Expand Down

0 comments on commit 5e80591

Please sign in to comment.