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

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

#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Serialize, Deserialize)]
#[sea_orm(table_name = "recurrence_rule")]
#[sea_orm::model]
#[serde(rename_all = "camelCase")]
pub struct Model {
    #[sea_orm(primary_key, auto_increment = false)]
    pub id: Uuid,
    pub r#type: RecurrenceType,
    pub interval: i32,
    pub by_weekday: Option<i32>,
    pub by_monthday: Option<i32>,
    pub timezone: String,
    pub created_at: DateTimeWithTimeZone,
    pub updated_at: DateTimeWithTimeZone,
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
    #[sea_orm(has_many = "super::reminder_task::Entity")]
    ReminderTask,
    #[sea_orm(has_many = "super::todo::Entity")]
    Todo,
}

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

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

impl ActiveModelBehavior for ActiveModel {}
