a8078f787c
Add Status field (gorm, indexed, default active) to both User and File models. Add User status constants: StatusActive, StatusAdminDeleted. Add File status constant: StatusUserDeleted. Add tests verifying Status field is excluded from JSON serialization. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
25 lines
1.1 KiB
Go
25 lines
1.1 KiB
Go
package model
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
// StatusUserDeleted marks a file that has been deleted by the user (soft delete).
|
|
const StatusUserDeleted = "user_deleted"
|
|
|
|
// File represents a file or directory entry in the virtual filesystem.
|
|
type File struct {
|
|
ID string `gorm:"primaryKey;type:varchar(36)" json:"id"`
|
|
UserID string `gorm:"index;uniqueIndex:idx_user_parent_name,priority:1;type:varchar(36);not null" json:"user_id"`
|
|
ParentID *string `gorm:"index;uniqueIndex:idx_user_parent_name,priority:2;type:varchar(36)" json:"parent_id"`
|
|
Name string `gorm:"type:varchar(255);not null;uniqueIndex:idx_user_parent_name,priority:3" json:"name"`
|
|
Size int64 `gorm:"default:0" json:"size"`
|
|
MimeType string `gorm:"type:varchar(127)" json:"mime_type"`
|
|
StoragePath string `gorm:"type:varchar(512)" json:"storage_path"`
|
|
Hash string `gorm:"type:varchar(64)" json:"-"`
|
|
Status string `gorm:"type:varchar(32);not null;default:active;index" json:"-"`
|
|
IsDir bool `gorm:"default:false" json:"is_dir"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|