use sea_orm::entity::prelude::*; use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Serialize, Deserialize)] #[sea_orm(table_name = "ai_chat_messages")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: Uuid, pub tenant_id: Uuid, pub session_id: Uuid, pub role: String, pub content: Option, pub tool_calls: Option, pub tool_call_id: Option, pub token_count: Option, pub created_at: DateTimeUtc, pub updated_at: DateTimeUtc, pub created_by: Option, pub updated_by: Option, pub deleted_at: Option, #[sea_orm(default_value = 1)] pub version_lock: i32, } #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] pub enum Relation { #[sea_orm( belongs_to = "super::ai_chat_session::Entity", from = "Column::SessionId", to = "super::ai_chat_session::Column::Id" )] Session, } impl Related for Entity { fn to() -> RelationDef { Relation::Session.def() } } impl ActiveModelBehavior for ActiveModel {}