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

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

#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)]
#[sea_orm(table_name = "projects")]
pub struct Model {
    pub created_at: DateTimeWithTimeZone,
    pub updated_at: DateTimeWithTimeZone,
    #[sea_orm(primary_key)]
    pub id: i32,
    pub name: String,
    pub technology: String,
    pub short_description: String,
    pub description: Option<String>,
    pub category: String,
    pub github_url: Option<String>,
    pub download_url: Option<String>,
    pub visit_url: Option<String>,
    pub is_highlighted: bool,
    pub is_archived: bool,
}

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

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

impl Related<super::data::Entity> for Entity {
    fn to() -> RelationDef {
        super::project_thumbnails::Relation::Data.def()
    }
    fn via() -> Option<RelationDef> {
        Some(super::project_thumbnails::Relation::Projects.def().rev())
    }
}
