veza/veza-backend-api/internal/models/data_export.go

35 lines
1.1 KiB
Go
Raw Normal View History

package models
import (
"time"
"github.com/google/uuid"
"gorm.io/gorm"
)
// DataExport represents a GDPR data export job (v0.10.8 F065)
type DataExport struct {
ID uuid.UUID `gorm:"type:uuid;primaryKey" json:"id"`
UserID uuid.UUID `gorm:"type:uuid;not null" json:"user_id"`
Status string `gorm:"type:varchar(20);not null;default:'pending'" json:"status"` // pending, processing, completed, failed
S3Key *string `gorm:"type:text" json:"s3_key,omitempty"`
FileSizeBytes *int64 `json:"file_size_bytes,omitempty"`
ExpiresAt time.Time `gorm:"not null" json:"expires_at"`
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
CompletedAt *time.Time `json:"completed_at,omitempty"`
ErrorMessage *string `gorm:"type:text" json:"error_message,omitempty"`
}
// TableName returns the table name for DataExport
func (DataExport) TableName() string {
return "data_exports"
}
// BeforeCreate generates UUID if not set
func (e *DataExport) BeforeCreate(tx *gorm.DB) error {
if e.ID == uuid.Nil {
e.ID = uuid.New()
}
return nil
}