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

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

#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "user")]
pub struct Model {
    #[sea_orm(primary_key)]
    pub id: i64,
    #[sea_orm(column_type = "Text", unique)]
    pub name: String,
    #[sea_orm(column_type = "Text")]
    pub pwd: String,
    #[sea_orm(column_type = "Text")]
    pub salt: String,
    pub is_admin: bool,
    pub is_read_only: bool,
    #[sea_orm(column_type = "Text")]
    pub created: String,
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
    #[sea_orm(has_many = "super::auth_token::Entity")]
    AuthToken,
    #[sea_orm(has_many = "super::crate_user::Entity")]
    CrateUser,
    #[sea_orm(has_many = "super::group_user::Entity")]
    GroupUser,
    #[sea_orm(has_many = "super::oauth2_identity::Entity")]
    OAuth2Identity,
    #[sea_orm(has_many = "super::owner::Entity")]
    Owner,
    #[sea_orm(has_many = "super::session::Entity")]
    Session,
}

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

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

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

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

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

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

impl ActiveModelBehavior for ActiveModel {}
