use sea_orm::entity::prelude::*; use serde::{Deserialize, Serialize}; use time::OffsetDateTime; use uuid::Uuid; #[derive( Debug, Clone, Copy, PartialEq, Eq, Default, EnumIter, DeriveActiveEnum, Serialize, Deserialize, )] #[sea_orm(rs_type = "i16", db_type = "SmallInteger")] pub enum ChatKind { #[default] Group = 0, Private = 1, } #[sea_orm::model] #[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)] #[sea_orm(table_name = "chat")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: Uuid, pub channel_id: Uuid, pub kind: ChatKind, pub counterpart_user_id: Option, pub title: Option, pub created_at: OffsetDateTime, pub updated_at: Option, #[sea_orm(belongs_to, from = "channel_id", to = "id")] pub channel: BelongsTo, #[sea_orm(belongs_to, from = "counterpart_user_id", to = "uid")] pub counterpart: BelongsTo>, } impl ActiveModelBehavior for ActiveModel {}