2026-07-23 12:03:47 +08:00
|
|
|
package model
|
|
|
|
|
|
|
|
|
|
import "time"
|
|
|
|
|
|
|
|
|
|
const (
|
|
|
|
|
TaskPending = "pending"
|
|
|
|
|
TaskValidating = "validating"
|
|
|
|
|
TaskDispatching = "dispatching"
|
|
|
|
|
TaskRunning = "running"
|
|
|
|
|
TaskRegistering = "registering"
|
|
|
|
|
TaskFinished = "finished"
|
|
|
|
|
TaskRegisterFailed = "register_failed"
|
|
|
|
|
TaskExecutionFailed = "execution_failed"
|
|
|
|
|
TaskValidationFailed = "validation_failed"
|
|
|
|
|
TaskCanceling = "canceling"
|
|
|
|
|
TaskCanceled = "canceled"
|
2026-07-28 14:29:09 +08:00
|
|
|
TaskRollbackPending = "rollback_pending"
|
|
|
|
|
TaskRollingBack = "rolling_back"
|
|
|
|
|
TaskRolledBack = "rolled_back"
|
|
|
|
|
TaskRollbackFailed = "rollback_failed"
|
|
|
|
|
TaskRollbackAck = "rollback_acknowledged"
|
2026-07-23 12:03:47 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type ResourceQuota struct {
|
|
|
|
|
ID uint64 `gorm:"primaryKey" json:"id"`
|
|
|
|
|
BusinessLineID uint64 `gorm:"not null;uniqueIndex:idx_resource_quota_scope,priority:1" json:"business_line_id"`
|
|
|
|
|
TargetID uint64 `gorm:"not null;uniqueIndex:idx_resource_quota_scope,priority:2" json:"target_id"`
|
|
|
|
|
CPUMilli int64 `gorm:"not null" json:"cpu_milli"`
|
|
|
|
|
MemoryMi int64 `gorm:"not null" json:"memory_mi"`
|
|
|
|
|
StorageGi int64 `gorm:"not null" json:"storage_gi"`
|
|
|
|
|
InstanceLimit int64 `gorm:"not null" json:"instance_limit"`
|
|
|
|
|
CreatedAt time.Time `json:"created_at"`
|
|
|
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type DeliveryTask struct {
|
|
|
|
|
ID string `gorm:"size:36;primaryKey" json:"id"`
|
|
|
|
|
BusinessLineID uint64 `gorm:"not null;index" json:"business_line_id"`
|
|
|
|
|
RequestedBy uint64 `gorm:"not null;index" json:"requested_by"`
|
2026-07-27 15:19:18 +08:00
|
|
|
Component string `gorm:"size:32;not null;default:mysql;index" json:"component"`
|
2026-07-23 12:03:47 +08:00
|
|
|
TargetType string `gorm:"size:32;not null" json:"target_type"`
|
|
|
|
|
TargetID uint64 `gorm:"not null;index" json:"target_id"`
|
|
|
|
|
Namespace string `gorm:"size:63;not null;index" json:"namespace"`
|
|
|
|
|
InstanceName string `gorm:"size:63;not null" json:"instance_name"`
|
|
|
|
|
TargetHost string `gorm:"size:128" json:"target_host,omitempty"`
|
|
|
|
|
TargetHostIP string `gorm:"size:64" json:"target_host_ip,omitempty"`
|
|
|
|
|
MySQLPort int `gorm:"column:mysql_port;not null;default:3307" json:"mysql_port"`
|
|
|
|
|
Status string `gorm:"size:32;not null;index" json:"status"`
|
|
|
|
|
ImmutablePayload string `gorm:"type:json;not null" json:"immutable_payload"`
|
|
|
|
|
PayloadHash string `gorm:"size:64;not null" json:"payload_hash"`
|
|
|
|
|
IdempotencyKey string `gorm:"size:128;not null;uniqueIndex" json:"idempotency_key"`
|
|
|
|
|
ErrorMessage string `gorm:"type:text" json:"error_message,omitempty"`
|
|
|
|
|
CreatedAt time.Time `gorm:"index" json:"created_at"`
|
|
|
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
|
|
|
StartedAt *time.Time `json:"started_at,omitempty"`
|
|
|
|
|
FinishedAt *time.Time `json:"finished_at,omitempty"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type ResourceReservation struct {
|
|
|
|
|
ID uint64 `gorm:"primaryKey" json:"id"`
|
|
|
|
|
TaskID string `gorm:"size:36;not null;uniqueIndex" json:"task_id"`
|
|
|
|
|
BusinessLineID uint64 `gorm:"not null;index" json:"business_line_id"`
|
|
|
|
|
TargetID uint64 `gorm:"not null;index" json:"target_id"`
|
|
|
|
|
CPUMilli int64 `gorm:"not null" json:"cpu_milli"`
|
|
|
|
|
MemoryMi int64 `gorm:"not null" json:"memory_mi"`
|
|
|
|
|
StorageGi int64 `gorm:"not null" json:"storage_gi"`
|
|
|
|
|
InstanceCount int64 `gorm:"not null;default:1" json:"instance_count"`
|
|
|
|
|
Status string `gorm:"size:32;not null;index" json:"status"`
|
|
|
|
|
ExpiresAt time.Time `gorm:"not null;index" json:"expires_at"`
|
|
|
|
|
CreatedAt time.Time `json:"created_at"`
|
|
|
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type ResourceUsage struct {
|
|
|
|
|
ID uint64 `gorm:"primaryKey" json:"id"`
|
|
|
|
|
TaskID string `gorm:"size:36;not null;uniqueIndex" json:"task_id"`
|
|
|
|
|
InstanceID uint64 `gorm:"not null;uniqueIndex" json:"instance_id"`
|
|
|
|
|
BusinessLineID uint64 `gorm:"not null;index" json:"business_line_id"`
|
|
|
|
|
TargetID uint64 `gorm:"not null;index" json:"target_id"`
|
|
|
|
|
CPUMilli int64 `gorm:"not null" json:"cpu_milli"`
|
|
|
|
|
MemoryMi int64 `gorm:"not null" json:"memory_mi"`
|
|
|
|
|
StorageGi int64 `gorm:"not null" json:"storage_gi"`
|
|
|
|
|
InstanceCount int64 `gorm:"not null;default:1" json:"instance_count"`
|
|
|
|
|
Status string `gorm:"size:32;not null;index" json:"status"`
|
|
|
|
|
CreatedAt time.Time `json:"created_at"`
|
|
|
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
|
|
|
ReleasedAt *time.Time `json:"released_at,omitempty"`
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-28 17:56:00 +08:00
|
|
|
type DeploymentResult struct {
|
2026-07-23 12:03:47 +08:00
|
|
|
ID uint64 `gorm:"primaryKey" json:"id"`
|
|
|
|
|
TaskID string `gorm:"size:36;not null;uniqueIndex" json:"task_id"`
|
|
|
|
|
BusinessLineID uint64 `gorm:"not null;index" json:"business_line_id"`
|
2026-07-28 17:56:00 +08:00
|
|
|
Component string `gorm:"size:32;not null;index" json:"component"`
|
|
|
|
|
ServiceType string `gorm:"size:32;not null;index" json:"service_type"`
|
|
|
|
|
InstanceName string `gorm:"size:128;not null;index" json:"instance_name"`
|
|
|
|
|
Namespace string `gorm:"size:128;not null;default:'';index" json:"namespace"`
|
|
|
|
|
TargetID uint64 `gorm:"not null;index" json:"target_id"`
|
|
|
|
|
NodeName string `gorm:"size:128;not null;default:''" json:"node_name"`
|
|
|
|
|
Host string `gorm:"size:255;not null;default:''" json:"host"`
|
|
|
|
|
Port int `gorm:"not null;default:0" json:"port"`
|
|
|
|
|
Version string `gorm:"size:64;not null;default:''" json:"version"`
|
2026-07-23 12:03:47 +08:00
|
|
|
Status string `gorm:"size:32;not null;index" json:"status"`
|
2026-07-28 17:56:00 +08:00
|
|
|
Metadata string `gorm:"type:json" json:"metadata"`
|
2026-07-23 12:03:47 +08:00
|
|
|
CreatedAt time.Time `json:"created_at"`
|
|
|
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-28 17:56:00 +08:00
|
|
|
type DeploymentCredential struct {
|
|
|
|
|
ID uint64 `gorm:"primaryKey" json:"id"`
|
|
|
|
|
TaskID string `gorm:"size:36;not null;index" json:"task_id"`
|
|
|
|
|
DeploymentResultID uint64 `gorm:"not null;default:0;index" json:"deployment_result_id"`
|
|
|
|
|
BusinessLineID uint64 `gorm:"not null;index" json:"business_line_id"`
|
|
|
|
|
Component string `gorm:"size:32;not null;index" json:"component"`
|
|
|
|
|
InstanceName string `gorm:"size:128;not null;index" json:"instance_name"`
|
|
|
|
|
Username string `gorm:"size:128;not null" json:"username"`
|
|
|
|
|
AccountHost string `gorm:"size:128;not null;default:''" json:"account_host"`
|
|
|
|
|
Ciphertext string `gorm:"type:text;not null" json:"-"`
|
|
|
|
|
Nonce string `gorm:"size:64;not null" json:"-"`
|
|
|
|
|
Status string `gorm:"size:32;not null;index" json:"status"`
|
|
|
|
|
Source string `gorm:"size:64;not null;default:'user_input'" json:"source"`
|
|
|
|
|
ViewedBy uint64 `gorm:"not null;default:0" json:"viewed_by"`
|
|
|
|
|
ViewedAt *time.Time `json:"viewed_at,omitempty"`
|
|
|
|
|
CreatedAt time.Time `json:"created_at"`
|
|
|
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-23 12:03:47 +08:00
|
|
|
type ExecutionJob struct {
|
|
|
|
|
ID uint64 `gorm:"primaryKey" json:"id"`
|
|
|
|
|
TaskID string `gorm:"size:36;not null;uniqueIndex" json:"task_id"`
|
|
|
|
|
IdempotencyKey string `gorm:"size:128;not null;uniqueIndex" json:"idempotency_key"`
|
|
|
|
|
ExecutorJobID string `gorm:"size:128;not null;uniqueIndex" json:"executor_job_id"`
|
|
|
|
|
Status string `gorm:"size:32;not null;index" json:"status"`
|
|
|
|
|
StartedAt *time.Time `json:"started_at,omitempty"`
|
|
|
|
|
FinishedAt *time.Time `json:"finished_at,omitempty"`
|
|
|
|
|
CreatedAt time.Time `json:"created_at"`
|
|
|
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-28 14:29:09 +08:00
|
|
|
// RollbackJob tracks the compensating AWX run independently from the deploy run.
|
|
|
|
|
// Keeping a separate record preserves both job IDs for audit and retry tooling.
|
|
|
|
|
type RollbackJob struct {
|
|
|
|
|
ID uint64 `gorm:"primaryKey" json:"id"`
|
|
|
|
|
TaskID string `gorm:"size:36;not null;uniqueIndex" json:"task_id"`
|
|
|
|
|
ExecutorJobID string `gorm:"size:128;not null" json:"executor_job_id"`
|
|
|
|
|
Status string `gorm:"size:32;not null;index" json:"status"`
|
|
|
|
|
Reason string `gorm:"type:text" json:"reason"`
|
|
|
|
|
StartedAt *time.Time `json:"started_at,omitempty"`
|
|
|
|
|
FinishedAt *time.Time `json:"finished_at,omitempty"`
|
|
|
|
|
CreatedAt time.Time `json:"created_at"`
|
|
|
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-23 12:03:47 +08:00
|
|
|
type TaskEvent struct {
|
2026-07-27 15:19:18 +08:00
|
|
|
ID uint64 `gorm:"primaryKey" json:"id"`
|
|
|
|
|
TaskID string `gorm:"size:36;not null;index" json:"task_id"`
|
|
|
|
|
FromState string `gorm:"size:32;not null" json:"from_state"`
|
|
|
|
|
ToState string `gorm:"size:32;not null" json:"to_state"`
|
|
|
|
|
Stage string `gorm:"size:32;index" json:"stage,omitempty"`
|
|
|
|
|
EventStatus string `gorm:"size:32;index" json:"event_status,omitempty"`
|
|
|
|
|
Message string `gorm:"type:text" json:"message"`
|
|
|
|
|
CreatedAt time.Time `gorm:"index" json:"created_at"`
|
2026-07-23 12:03:47 +08:00
|
|
|
}
|