//! `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 = "cratesio_crate")]
pub struct Model {
    #[sea_orm(primary_key)]
    pub id: i64,
    #[sea_orm(column_type = "Text", unique)]
    pub name: String,
    #[sea_orm(column_type = "Text", unique)]
    pub original_name: String,
    pub e_tag: String,
    #[sea_orm(column_type = "Text")]
    pub last_modified: String,
    #[sea_orm(column_type = "Text", nullable)]
    pub description: Option<String>,
    pub total_downloads: i64,
    #[sea_orm(column_type = "Text")]
    pub max_version: String,
}

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

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

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

impl ActiveModelBehavior for ActiveModel {}
