46
internal/models/file_object.go
Normal file
46
internal/models/file_object.go
Normal file
@@ -0,0 +1,46 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type FileStatus string
|
||||
|
||||
const (
|
||||
FileStatusPending FileStatus = "pending"
|
||||
FileStatusReady FileStatus = "ready"
|
||||
FileStatusDeleting FileStatus = "deleting"
|
||||
FileStatusExpired FileStatus = "expired"
|
||||
)
|
||||
|
||||
type FileObject struct {
|
||||
ID uint `gorm:"primaryKey" json:"id"`
|
||||
Identity string `gorm:"size:64;not null;uniqueIndex" json:"identity"`
|
||||
Namespace string `gorm:"size:64;not null" json:"namespace"`
|
||||
Provider string `gorm:"size:32;not null" json:"provider"`
|
||||
Bucket string `gorm:"size:255;not null" json:"bucket"`
|
||||
ObjectKey string `gorm:"size:512;not null;uniqueIndex" json:"object_key"`
|
||||
OriginalName string `gorm:"size:255;not null" json:"original_name"`
|
||||
Extension string `gorm:"size:32" json:"extension"`
|
||||
ContentType string `gorm:"size:255" json:"content_type"`
|
||||
ExpectedSize int64 `gorm:"not null" json:"expected_size"`
|
||||
ActualSize int64 `json:"actual_size"`
|
||||
ETag string `gorm:"size:255" json:"etag"`
|
||||
Status FileStatus `gorm:"size:16;not null;index:idx_files_object_status_expires_at,priority:1;index:idx_files_object_status_delete_lease,priority:1" json:"status"`
|
||||
OwnerType string `gorm:"size:64;not null;index:idx_files_object_owner_type_identity,priority:1" json:"owner_type"`
|
||||
OwnerID uint `gorm:"not null" json:"owner_id"`
|
||||
OwnerIdentity string `gorm:"size:64;not null;index:idx_files_object_owner_type_identity,priority:2" json:"owner_identity"`
|
||||
ExpiresAt *time.Time `gorm:"index:idx_files_object_status_expires_at,priority:2" json:"expires_at"`
|
||||
CompletedAt *time.Time `json:"completed_at"`
|
||||
DeleteToken string `gorm:"size:26" json:"-"`
|
||||
DeleteLeaseUntil *time.Time `gorm:"index:idx_files_object_status_delete_lease,priority:2" json:"-"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"index" json:"deleted_at,omitempty"`
|
||||
}
|
||||
|
||||
func (FileObject) TableName() string {
|
||||
return "files_object"
|
||||
}
|
||||
Reference in New Issue
Block a user