Files
kevin 6949b12af0 增加文件表与文件操作记录表
- files 表:相对路径、MIME、扩展名、大小、sha256 唯一(秒传)、引用计数、上传者、存储后端、元数据等
- file_operations 表:create/download/rename/move/delete 五种操作,含文件快照、操作人快照与 IP
- 迁移 v8、v9;补充 hash 唯一约束与操作日志读写测试
2026-09-21 20:28:34 +08:00

29 lines
1.2 KiB
Go

package model
import "time"
// 文件状态。
const (
FileStatusDisabled int8 = 0
FileStatusEnabled int8 = 1
)
// File 上传文件元数据。Path 相对存储根目录,Hash 唯一用于秒传去重。
type File struct {
ID uint `gorm:"primaryKey" json:"id"`
Name string `gorm:"size:255;not null" json:"name"`
Path string `gorm:"size:512;not null" json:"path"`
Extension string `gorm:"size:20" json:"extension"`
MimeType string `gorm:"size:100" json:"mime_type"`
Size int64 `gorm:"not null;default:0" json:"size"`
Hash string `gorm:"size:64;uniqueIndex;not null" json:"hash"`
RefCount int64 `gorm:"not null;default:0" json:"ref_count"`
UploaderID *uint `gorm:"index" json:"uploader_id"`
Storage string `gorm:"size:20;not null;default:'local'" json:"storage"`
Status int8 `gorm:"not null;default:1" json:"status"`
Metadata string `gorm:"type:text" json:"metadata"`
LastReferencedAt *time.Time `json:"last_referenced_at"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}