Files
oxspeak_server/src/models/message.rs
T
2026-08-17 01:12:07 +02:00

63 lines
1.7 KiB
Rust

//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.19
use sea_orm::Set;
use sea_orm::entity::prelude::*;
use sea_orm::prelude::async_trait::async_trait;
#[sea_orm::model]
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "message")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: Uuid,
pub channel_id: Uuid,
pub user_id: Uuid,
#[sea_orm(column_type = "Text")]
pub content: String,
pub created_at: DateTimeUtc,
pub updated_at: Option<DateTimeUtc>,
pub reply_to_id: Option<Uuid>,
#[sea_orm(has_many)]
pub attachments: HasMany<super::attachment::Entity>,
#[sea_orm(has_many)]
pub reactions: HasMany<super::message_reaction::Entity>,
#[sea_orm(
belongs_to,
from = "channel_id",
to = "id",
on_update = "NoAction",
on_delete = "Cascade"
)]
pub channel: HasOne<super::channel::Entity>,
#[sea_orm(
self_ref,
relation_enum = "ReplyTo",
relation_reverse = "Replies",
from = "reply_to_id",
to = "id",
on_update = "NoAction",
on_delete = "SetNull"
)]
pub reply_to: HasOne<Entity>,
#[sea_orm(self_ref, relation_enum = "Replies", relation_reverse = "ReplyTo")]
pub replies: HasMany<Entity>,
#[sea_orm(
belongs_to,
from = "user_id",
to = "id",
on_update = "NoAction",
on_delete = "Cascade"
)]
pub user: HasOne<super::user::Entity>,
}
#[async_trait]
impl ActiveModelBehavior for ActiveModel {
fn new() -> Self {
Self {
id: Set(Uuid::now_v7()),
..ActiveModelTrait::default()
}
}
}