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, pub target_url: Option, pub creator_id: i64, pub created_at: OffsetDateTime, pub updated_at: Option, #[sea_orm(belongs_to, from = "(repo_id, sha)", to = "(repo_id, sha)")] pub commit: BelongsTo, #[sea_orm(belongs_to, from = "creator_id", to = "uid")] pub creator: BelongsTo, } impl ActiveModelBehavior for ActiveModel {}