Skip to content
Clone
e1df092
56 lines 1.4 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,
)]
#[sea_orm(rs_type = "i16", db_type = "SmallInteger")]
pub enum CommitStatusState {
#[default]
#[sea_orm(num_value = 0)]
Pending,
#[sea_orm(num_value = 1)]
Success,
#[sea_orm(num_value = 2)]
Failure,
#[sea_orm(num_value = 3)]
Error,
}
#[sea_orm::model]
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
#[sea_orm(table_name = "git_commit_status")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: Uuid,
#[sea_orm(unique_key = "commit")]
pub repo_id: Uuid,
#[sea_orm(unique_key = "commit")]
pub sha: String,
pub state: CommitStatusState,
#[sea_orm(unique_key = "commit")]
pub context: String,
pub description: Option<String>,
pub target_url: Option<String>,
pub creator_id: i64,
pub created_at: OffsetDateTime,
pub updated_at: Option<OffsetDateTime>,
#[sea_orm(belongs_to, from = "(repo_id, sha)", to = "(repo_id, sha)")]
pub commit: BelongsTo<super::git_commits::Entity>,
#[sea_orm(belongs_to, from = "creator_id", to = "uid")]
pub creator: BelongsTo<super::super::users::user::Entity>,
}
impl ActiveModelBehavior for ActiveModel {}