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 IssuePriority { #[default] #[sea_orm(num_value = 0)] None, #[sea_orm(num_value = 1)] Low, #[sea_orm(num_value = 2)] Medium, #[sea_orm(num_value = 3)] High, #[sea_orm(num_value = 4)] Urgent, } #[sea_orm::model] #[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)] #[sea_orm(table_name = "issue")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: Uuid, #[sea_orm(unique_key = "collection_number")] pub collection_id: Uuid, #[sea_orm(unique_key = "collection_number")] pub autoincrement_id: i32, pub author_id: i64, pub title: String, pub description: Option, pub body: String, pub milestone_id: Option, #[sea_orm(default_value = 0)] pub priority: IssuePriority, pub due_at: Option, pub created_at: OffsetDateTime, pub updated_at: Option, pub closed_at: Option, #[sea_orm(belongs_to, from = "collection_id", to = "id")] pub collection: BelongsTo, #[sea_orm(belongs_to, from = "author_id", to = "uid")] pub author: BelongsTo, #[sea_orm(belongs_to, from = "milestone_id", to = "id")] pub milestone: BelongsTo>, } impl ActiveModelBehavior for ActiveModel {}