weftgraph 0.1.0

Graph Storage gear: typed, multi-tenant knowledge graph with search and traversal over a pluggable store
Documentation
//! Graph edges (`cpt-cf-graph-storage-dbtable-edge`).
//!
//! Endpoint foreign keys are `ON DELETE RESTRICT`, never CASCADE: deletion
//! never cascades into edges, so an analysis edge can never be destroyed as a
//! side effect of removing a static node.

use sea_orm::entity::prelude::*;
use time::OffsetDateTime;
use toolkit_db_macros::Scopable;
use uuid::Uuid;

#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Scopable)]
#[sea_orm(table_name = "edge")]
#[secure(tenant_col = "tenant_id", resource_col = "id", no_owner, no_type)]
pub struct Model {
    #[sea_orm(primary_key, auto_increment = false)]
    pub tenant_id: Uuid,
    #[sea_orm(primary_key, auto_increment = false)]
    pub id: i64,
    /// Deterministic hash of (type, src, dst, discriminator).
    pub edge_key: String,
    /// Interned type reference into `gts_type`.
    pub gts_edge_type_id: i32,
    pub src_node_id: i64,
    pub dst_node_id: i64,
    /// Distinguishes parallel edges of one type between one endpoint pair.
    pub discriminator: Option<String>,
    /// GTS-validated attributes, including provenance for analysis edges.
    pub payload: Json,
    pub created_at: OffsetDateTime,
    /// An edge carries the same audit columns as a node. A re-synced static
    /// edge is rewritten rather than versioned, so `updated_by` records the
    /// last producer to assert the relationship -- which is the question
    /// asked when two producers claim the same one.
    pub updated_at: OffsetDateTime,
    /// Soft-delete tombstone; `NULL` for live rows.
    pub deleted_at: Option<OffsetDateTime>,
    /// The scope whose declared snapshot this edge belongs to, when a scoped
    /// batch wrote it. `NULL` means no scope has declared it, and a
    /// replacement leaves it alone unless an endpoint is departing.
    pub scope_attribute: Option<String>,
    pub scope_value: Option<String>,
    /// Subject that first wrote the row (DESIGN ยง API element envelope).
    pub created_by_subject_id: Uuid,
    pub created_by_subject_type: Option<String>,
    /// Subject of the most recent write.
    pub updated_by_subject_id: Uuid,
    pub updated_by_subject_type: Option<String>,
    /// Subject that tombstoned the row; `NULL` while live.
    pub deleted_by_subject_id: Option<Uuid>,
    pub deleted_by_subject_type: Option<String>,
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {}

impl ActiveModelBehavior for ActiveModel {}