//! `SeaORM` Entity, @generated by sea-orm-codegen 2.0

use super::sea_orm_active_enums::ChannelType;
use super::sea_orm_active_enums::NotificationStatus;
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Serialize, Deserialize)]
#[sea_orm(table_name = "delivery_log")]
#[sea_orm::model]
pub struct Model {
    #[sea_orm(primary_key, auto_increment = false)]
    pub id: Uuid,
    pub notification_id: Uuid,
    pub attempt_no: i32,
    pub channel: ChannelType,
    pub status: NotificationStatus,
    #[sea_orm(column_type = "JsonBinary", nullable)]
    pub response_meta: Option<Json>,
    pub created_at: DateTimeWithTimeZone,
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
    #[sea_orm(
        belongs_to = "super::notification::Entity",
        from = "Column::NotificationId",
        to = "super::notification::Column::Id",
        on_update = "Cascade",
        on_delete = "Cascade"
    )]
    Notification,
}

impl Related<super::notification::Entity> for Entity {
    fn to() -> RelationDef {
        Relation::Notification.def()
    }
}

impl ActiveModelBehavior for ActiveModel {}
