use sea_orm::entity::prelude::*; use time::OffsetDateTime; use uuid::Uuid; #[sea_orm::model] #[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)] #[sea_orm(table_name = "chat_messages")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: Uuid, #[sea_orm(indexed)] pub chat_id: Uuid, pub sender_id: Uuid, pub body: String, pub reply_to_message_id: Option, pub thread_id: Option, pub is_thread_start: bool, pub flags: i64, pub deleted_at: Option, pub deleted_by: Option, pub edited_at: Option, #[sea_orm(indexed)] pub created_at: OffsetDateTime, #[sea_orm(belongs_to, from = "chat_id", to = "id")] pub chat: BelongsTo, #[sea_orm(belongs_to, from = "sender_id", to = "uid")] pub sender: BelongsTo, #[sea_orm( self_ref, relation_enum = "ReplyTo", relation_reverse = "Replies", from = "reply_to_message_id", to = "id" )] pub reply_to: HasOne, #[sea_orm( belongs_to, relation_enum = "DeletedBy", from = "deleted_by", to = "uid" )] pub deleted_by_user: BelongsTo>, } impl ActiveModelBehavior for ActiveModel {}