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

use sea_orm::entity::prelude::*;

#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "user")]
pub struct Model {
    #[sea_orm(primary_key, auto_increment = false)]
    pub id: String,
    #[sea_orm(unique)]
    pub username: String,
    pub display_name: Option<String>,
    pub email: String,
    pub new_email: Option<String>,
    pub password: String,
    pub flags: i64,
    pub created_on: DateTime,
    pub last_updated: DateTime,
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
    #[sea_orm(has_many = "super::announcement::Entity")]
    Announcement,
    #[sea_orm(has_many = "super::invite_code::Entity")]
    InviteCode,
    #[sea_orm(has_many = "super::user_session::Entity")]
    UserSession,
    #[sea_orm(has_one = "super::user_settings::Entity")]
    UserSettings,
}

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

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

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

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

impl ActiveModelBehavior for ActiveModel {}
