diff --git a/internal/file/file.go b/internal/file/file.go index ca02e31..218d2bf 100644 --- a/internal/file/file.go +++ b/internal/file/file.go @@ -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:"-"` } diff --git a/pkg/ftp/record.go b/pkg/ftp/record.go index 08eed92..9b79fc0 100644 --- a/pkg/ftp/record.go +++ b/pkg/ftp/record.go @@ -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:"-"` } diff --git a/pkg/mysql/record.go b/pkg/mysql/record.go index 7784068..2130f5b 100644 --- a/pkg/mysql/record.go +++ b/pkg/mysql/record.go @@ -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:"-"` }