//! SeaORM Entity. Generated by sea-orm-codegen 0.9.3

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

#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
#[sea_orm(table_name = "application")]
pub struct Model {
    #[sea_orm(primary_key, auto_increment = false)]
    pub id: i32,
    pub candidate_id: i32,
    pub field_of_study: String,
    pub password: String,
    pub public_key: String,
    pub private_key: String,
    pub personal_id_number: String,
    pub created_at: DateTime,
    pub updated_at: DateTime,
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
    #[sea_orm(
        belongs_to = "super::candidate::Entity",
        from = "Column::CandidateId",
        to = "super::candidate::Column::Id",
        on_update = "Cascade",
        on_delete = "Cascade"
    )]
    Candidate,
    #[sea_orm(has_many = "super::session::Entity")]
    Session,
}

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

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

impl ActiveModelBehavior for ActiveModel {}
