use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Serialize, Deserialize)]
#[sea_orm(table_name = "dead_letter_events")]
pub struct Model {
    #[sea_orm(primary_key, auto_increment = false)]
    pub id: Uuid,
    #[sea_orm(skip_serializing_if = "Option::is_none")]
    pub tenant_id: Option<Uuid>,
    pub original_event_id: Uuid,
    pub event_type: String,
    #[sea_orm(skip_serializing_if = "Option::is_none")]
    pub payload: Option<serde_json::Value>,
    pub consumer_id: String,
    pub attempts: i32,
    #[sea_orm(skip_serializing_if = "Option::is_none")]
    pub last_error: Option<String>,
    pub created_at: DateTimeUtc,
    #[sea_orm(skip_serializing_if = "Option::is_none")]
    pub resolved_at: Option<DateTimeUtc>,
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {}

impl ActiveModelBehavior for ActiveModel {}
