2026-03-10 12:57:04 +00:00
|
|
|
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 {
|
2026-04-14 10:22:14 +00:00
|
|
|
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"`
|
2026-03-10 12:57:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
}
|