Skip to content
Clone
194c44c
62 lines 1.6 KB Rust
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 DeploymentState {
#[default]
#[sea_orm(num_value = 0)]
Pending,
#[sea_orm(num_value = 1)]
Running,
#[sea_orm(num_value = 2)]
Success,
#[sea_orm(num_value = 3)]
Failure,
#[sea_orm(num_value = 4)]
Cancelled,
}
#[sea_orm::model]
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
#[sea_orm(table_name = "ci_deployment")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: Uuid,
#[sea_orm(indexed)]
pub environment_id: Uuid,
pub run_id: Uuid,
pub job_id: Uuid,
pub repo_id: Uuid,
pub commit_sha: String,
pub git_ref: String,
pub state: DeploymentState,
pub actor_id: Option<i64>,
pub created_at: OffsetDateTime,
pub updated_at: OffsetDateTime,
#[sea_orm(belongs_to, from = "environment_id", to = "id")]
pub environment: BelongsTo<super::ci_environment::Entity>,
#[sea_orm(belongs_to, from = "run_id", to = "id")]
pub run: BelongsTo<super::workflow_run::Entity>,
#[sea_orm(belongs_to, from = "job_id", to = "id")]
pub job: BelongsTo<super::workflow_job::Entity>,
#[sea_orm(belongs_to, from = "repo_id", to = "id")]
pub repo: BelongsTo<super::super::repo::repos::Entity>,
}
impl ActiveModelBehavior for ActiveModel {}