knowdit_kg_model/db/project_semantic.rs
1//! Many-to-many between historical projects and semantic-graph nodes.
2//!
3//! Replaces the old `semantic_node.project_id` column. A canonical (merged)
4//! semantic node may participate in many historical projects, so the
5//! provenance link lives in this side table instead of being scalar on the
6//! semantic row. Each row records "project P contributed (or shares) semantic
7//! S". The same `(project_id, semantic_node_id)` pair must not be inserted
8//! twice — the composite primary key enforces that.
9//!
10//! Note: `semantic_node_id` here may reference either a canonical node or a
11//! merged-away (raw) node. Consumers that need only canonical visibility
12//! should resolve through `semantic_merge`.
13use sea_orm::entity::prelude::*;
14
15#[sea_orm::model]
16#[derive(Clone, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize, DeriveEntityModel)]
17#[sea_orm(table_name = "project_semantic")]
18pub struct Model {
19 #[sea_orm(primary_key, auto_increment = false)]
20 pub project_id: i32,
21 #[sea_orm(primary_key, auto_increment = false)]
22 pub semantic_node_id: i32,
23
24 #[sea_orm(belongs_to, from = "project_id", to = "id")]
25 pub project: Option<super::project::Entity>,
26 #[sea_orm(belongs_to, from = "semantic_node_id", to = "id")]
27 pub semantic_node: Option<super::semantic_node::Entity>,
28}
29
30impl ActiveModelBehavior for ActiveModel {}