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 IssueMemberKind { #[default] #[sea_orm(num_value = 0)] Assignee, #[sea_orm(num_value = 1)] Mentioned, #[sea_orm(num_value = 2)] Participant, } #[sea_orm::model] #[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)] #[sea_orm(table_name = "issue_member")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: Uuid, #[sea_orm(unique_key = "issue_user_kind")] pub issue_id: Uuid, #[sea_orm(unique_key = "issue_user_kind")] pub user_id: i64, #[sea_orm(unique_key = "issue_user_kind")] pub kind: IssueMemberKind, pub created_at: OffsetDateTime, pub updated_at: Option, #[sea_orm(belongs_to, from = "issue_id", to = "id")] pub issue: BelongsTo, #[sea_orm(belongs_to, from = "user_id", to = "uid")] pub user: BelongsTo, } impl ActiveModelBehavior for ActiveModel {}