Skip to content
Clone
a06673b
38 lines 1.2 KB Rust
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 = "String", db_type = "String(StringLen::N(16))")]
pub enum ScheduledMessageStatus {
#[default]
#[sea_orm(string_value = "pending")]
Pending,
#[sea_orm(string_value = "sent")]
Sent,
#[sea_orm(string_value = "cancelled")]
Cancelled,
}
#[sea_orm::model]
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
#[sea_orm(table_name = "user_scheduled_message")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: Uuid,
pub user_id: Uuid,
pub target_channel_id: Uuid,
pub payload: String,
pub scheduled_at: OffsetDateTime,
pub status: ScheduledMessageStatus,
pub created_at: OffsetDateTime,
#[sea_orm(belongs_to, from = "user_id", to = "uid")]
pub user: BelongsTo<super::users::Entity>,
#[sea_orm(belongs_to, from = "target_channel_id", to = "id")]
pub channel: BelongsTo<super::super::channel::channels::Entity>,
}
impl ActiveModelBehavior for ActiveModel {}