feat(db): add project_links entity
zhenyi committed
Added lib/db/project/project_links.rs lib/db/project/project_links.rs +39 −0 View lib/db/project/project_links.rs
@@ -0,0 +1,39 @@
1use sea_orm::entity::prelude::*;
2use serde::{Deserialize, Serialize};
3use time::OffsetDateTime;
4use uuid::Uuid;
5
6#[derive(
7 Debug, Clone, Copy, PartialEq, Eq, EnumIter, DeriveActiveEnum, Serialize, Deserialize,
8)]
9#[sea_orm(rs_type = "i32", db_type = "SmallInteger")]
10pub enum ProjectLinkKind {
11 Related = 0,
12 Duplicate = 1,
13 Blocks = 2,
14 BlockedBy = 3,
15}
16
17#[sea_orm::model]
18#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
19#[sea_orm(table_name = "project_links")]
20pub struct Model {
21 #[sea_orm(primary_key, auto_increment = false)]
22 pub id: Uuid,
23 pub project_id: Uuid,
24 pub related_project_id: Uuid,
25 pub kind: ProjectLinkKind,
26 pub created_by: Uuid,
27 pub created_at: OffsetDateTime,
28 #[sea_orm(belongs_to, from = "project_id", to = "id")]
29 pub project: BelongsTo<super::project::Entity>,
30 #[sea_orm(
31 belongs_to,
32 relation_enum = "RelatedProject",
33 from = "related_project_id",
34 to = "id"
35 )]
36 pub related_project: BelongsTo<super::project::Entity>,
37}
38
39impl ActiveModelBehavior for ActiveModel {}