use sea_orm::entity::prelude::*; use serde::{Deserialize, Serialize}; use time::OffsetDateTime; use uuid::Uuid; #[derive( Debug, Clone, Copy, PartialEq, Eq, Default, EnumIter, DeriveActiveEnum, Serialize, Deserialize, utoipa::ToSchema, )] #[serde(rename_all = "snake_case")] #[sea_orm(rs_type = "i16", db_type = "SmallInteger")] pub enum ArtifactState { #[default] #[sea_orm(num_value = 0)] Pending, #[sea_orm(num_value = 1)] Uploading, #[sea_orm(num_value = 2)] Ready, #[sea_orm(num_value = 3)] Failed, } #[sea_orm::model] #[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)] #[sea_orm(table_name = "workflow_artifact")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: Uuid, #[sea_orm(indexed)] pub run_id: Uuid, pub job_id: Uuid, pub name: String, pub object_key: String, pub size: i64, pub sha256: Option, pub state: ArtifactState, pub expires_at: Option, pub created_at: OffsetDateTime, pub updated_at: OffsetDateTime, #[sea_orm(belongs_to, from = "run_id", to = "id")] pub run: BelongsTo, #[sea_orm(belongs_to, from = "job_id", to = "id")] pub job: BelongsTo, } impl ActiveModelBehavior for ActiveModel {}