feat(attachments): add pipeline and outbox schema and queries
This commit is contained in:
+85
-12
@@ -98,19 +98,81 @@ func (ns NullAttachmentStatus) Value() (driver.Value, error) {
|
||||
return string(ns.AttachmentStatus), nil
|
||||
}
|
||||
|
||||
type AttachmentVariantName string
|
||||
|
||||
const (
|
||||
AttachmentVariantNameThumbnail AttachmentVariantName = "thumbnail"
|
||||
AttachmentVariantNameCrop AttachmentVariantName = "crop"
|
||||
AttachmentVariantNameOptimized AttachmentVariantName = "optimized"
|
||||
)
|
||||
|
||||
func (e *AttachmentVariantName) Scan(src interface{}) error {
|
||||
switch s := src.(type) {
|
||||
case []byte:
|
||||
*e = AttachmentVariantName(s)
|
||||
case string:
|
||||
*e = AttachmentVariantName(s)
|
||||
default:
|
||||
return fmt.Errorf("unsupported scan type for AttachmentVariantName: %T", src)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type NullAttachmentVariantName struct {
|
||||
AttachmentVariantName AttachmentVariantName
|
||||
Valid bool // Valid is true if AttachmentVariantName is not NULL
|
||||
}
|
||||
|
||||
// Scan implements the Scanner interface.
|
||||
func (ns *NullAttachmentVariantName) Scan(value interface{}) error {
|
||||
if value == nil {
|
||||
ns.AttachmentVariantName, ns.Valid = "", false
|
||||
return nil
|
||||
}
|
||||
ns.Valid = true
|
||||
return ns.AttachmentVariantName.Scan(value)
|
||||
}
|
||||
|
||||
// Value implements the driver Valuer interface.
|
||||
func (ns NullAttachmentVariantName) Value() (driver.Value, error) {
|
||||
if !ns.Valid {
|
||||
return nil, nil
|
||||
}
|
||||
return string(ns.AttachmentVariantName), nil
|
||||
}
|
||||
|
||||
type Attachment struct {
|
||||
ID uuid.UUID
|
||||
ChatID uuid.UUID
|
||||
OwnerID uuid.UUID
|
||||
S3Key string
|
||||
Filename string
|
||||
ContentType AttachmentContentType
|
||||
SizeBytes int
|
||||
Sha256 string
|
||||
Status AttachmentStatus
|
||||
ErrorCode *string
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
ID uuid.UUID
|
||||
ChatID uuid.UUID
|
||||
OwnerID uuid.UUID
|
||||
S3Key string
|
||||
Filename string
|
||||
ContentType AttachmentContentType
|
||||
SizeBytes int
|
||||
Sha256 string
|
||||
Status AttachmentStatus
|
||||
ErrorCode *string
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
StagingKey *string
|
||||
JobID *uuid.UUID
|
||||
PipelineVersion int
|
||||
Attempts int
|
||||
Width *int32
|
||||
Height *int32
|
||||
LeaseUntil *time.Time
|
||||
}
|
||||
|
||||
type AttachmentVariant struct {
|
||||
AttachmentID uuid.UUID
|
||||
PipelineVersion int
|
||||
Variant AttachmentVariantName
|
||||
S3Key string
|
||||
ContentType string
|
||||
SizeBytes int
|
||||
Sha256 string
|
||||
Width int
|
||||
Height int
|
||||
}
|
||||
|
||||
type Chat struct {
|
||||
@@ -148,6 +210,17 @@ type MessageAttachment struct {
|
||||
Position int
|
||||
}
|
||||
|
||||
type Outbox struct {
|
||||
ID int64
|
||||
JobID uuid.UUID
|
||||
AttachmentID uuid.UUID
|
||||
PipelineVersion int
|
||||
Attempt int
|
||||
CreatedAt time.Time
|
||||
AvailableAt time.Time
|
||||
PublishedAt *time.Time
|
||||
}
|
||||
|
||||
type Session struct {
|
||||
TokenHash string
|
||||
UserID uuid.UUID
|
||||
|
||||
Reference in New Issue
Block a user