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

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

#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)]
#[sea_orm(table_name = "users")]
pub struct Model {
    pub created_at: DateTimeWithTimeZone,
    pub updated_at: DateTimeWithTimeZone,
    #[sea_orm(primary_key)]
    pub id: i32,
    pub pid: Uuid,
    #[sea_orm(unique)]
    pub email: String,
    pub password: String,
    #[sea_orm(unique)]
    pub api_key: String,
    pub name: String,
    pub reset_token: Option<String>,
    pub reset_sent_at: Option<DateTimeWithTimeZone>,
    pub email_verification_token: Option<String>,
    pub email_verification_sent_at: Option<DateTimeWithTimeZone>,
    pub email_verified_at: Option<DateTimeWithTimeZone>,
    pub magic_link_token: Option<String>,
    pub magic_link_expiration: Option<DateTimeWithTimeZone>,
    pub theme: String,
    pub account_type: String,
    #[sea_orm(column_type = "Text", nullable)]
    pub totp_secret: Option<String>,
    pub totp_enabled_at: Option<DateTimeWithTimeZone>,
    #[sea_orm(column_type = "Text", nullable)]
    pub totp_backup_codes: Option<String>,
    pub avatar_id: Option<String>,
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
    #[sea_orm(has_many = "super::account_discount_profiles::Entity")]
    AccountDiscountProfiles,
    #[sea_orm(has_many = "super::account_product_prices::Entity")]
    AccountProductPrices,
    #[sea_orm(has_many = "super::account_product_resolutions::Entity")]
    AccountProductResolutions,
    #[sea_orm(has_many = "super::audit_logs::Entity")]
    AuditLogs,
    #[sea_orm(has_one = "super::customer_profiles::Entity")]
    CustomerProfiles,
    #[sea_orm(has_many = "super::o_auth2_sessions::Entity")]
    OAuth2Sessions,
}

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

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

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

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

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

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