use sea_orm::JsonValue; 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, utoipa::ToSchema, )] #[sea_orm(rs_type = "i16", db_type = "SmallInteger")] pub enum AttachmentStatus { #[default] #[sea_orm(num_value = 0)] Pending, #[sea_orm(num_value = 1)] Uploaded, } #[sea_orm::model] #[derive(Clone, Debug, PartialEq, DeriveEntityModel)] #[sea_orm(table_name = "chat_attachment")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: Uuid, #[sea_orm(indexed)] pub user_id: i64, #[sea_orm(indexed)] pub room_id: Option, #[sea_orm(indexed)] pub message_id: Option, pub filename: String, pub description: Option, pub content_type: String, pub size: i64, pub bucket: String, pub s3_key: String, #[sea_orm(default_value = 0)] pub status: AttachmentStatus, pub width: Option, pub height: Option, pub duration_secs: Option, #[sea_orm(column_type = "JsonBinary", default_value = "[]")] pub variants: JsonValue, pub created_at: OffsetDateTime, pub updated_at: OffsetDateTime, #[sea_orm(belongs_to, from = "user_id", to = "uid")] pub user: BelongsTo, } impl ActiveModelBehavior for ActiveModel {}