Skip to main content

knowdit_kg_model/db/
project_platform.rs

1use sea_orm::entity::prelude::*;
2
3/// 1:1 relation table mapping projects to their platform-specific IDs.
4/// Extracted from project.platform_id to avoid a unique nullable column.
5#[sea_orm::model]
6#[derive(Clone, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize, DeriveEntityModel)]
7#[sea_orm(table_name = "project_platform")]
8pub struct Model {
9    #[sea_orm(primary_key)]
10    pub id: i32,
11    /// The project this maps to (unique — at most one platform ID per project)
12    #[sea_orm(unique)]
13    pub project_id: i32,
14    /// Platform-specific ID, e.g. "c4-420" for Code4rena contest 420
15    pub platform_id: String,
16
17    #[sea_orm(belongs_to, from = "project_id", to = "id")]
18    pub project: HasOne<super::project::Entity>,
19}
20
21impl ActiveModelBehavior for ActiveModel {}