use crate::{DateTimeUtc, Decimal};
use sea_orm::entity::prelude::*;

#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
#[sea_orm(table_name = "workspace_alert_config")]
pub struct Model {
    #[sea_orm(primary_key)]
    pub id: i32,
    #[sea_orm(column_name = "workspace_id")]
    pub workspace_id: Uuid,
    #[sea_orm(column_type = "Text")]
    pub alert_type: String,
    /// Threshold value (e.g. 10.0 = balance < $10, 0.8 = 80% of quota used)
    #[sea_orm(column_type = "Decimal(Some((10, 4)))")]
    pub threshold: Decimal,
    #[sea_orm(default_value = "true")]
    pub email_enabled: bool,
    #[sea_orm(default_value = "true")]
    pub enabled: bool,
    /// admin_user.id (NULL if created via API without user context)
    #[sea_orm(nullable)]
    pub created_by: Option<i32>,
    pub created_at: DateTimeUtc,
    pub updated_at: DateTimeUtc,
}

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

impl ActiveModelBehavior for ActiveModel {}
