use sea_orm::entity::prelude::*; use serde::{Deserialize, Serialize}; use time::OffsetDateTime; use uuid::Uuid; #[derive( Debug, Clone, Copy, PartialEq, Eq, EnumIter, DeriveActiveEnum, Serialize, Deserialize, )] #[sea_orm(rs_type = "i32", db_type = "SmallInteger")] pub enum ProjectLinkKind { Related = 0, Duplicate = 1, Blocks = 2, BlockedBy = 3, } #[sea_orm::model] #[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)] #[sea_orm(table_name = "project_links")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: Uuid, pub project_id: Uuid, pub related_project_id: Uuid, pub kind: ProjectLinkKind, pub created_by: Uuid, pub created_at: OffsetDateTime, #[sea_orm(belongs_to, from = "project_id", to = "id")] pub project: BelongsTo, #[sea_orm( belongs_to, relation_enum = "RelatedProject", from = "related_project_id", to = "id" )] pub related_project: BelongsTo, } impl ActiveModelBehavior for ActiveModel {}