//! `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_meta")]
pub struct Model {
    #[sea_orm(primary_key)]
    pub id: i64,
    #[sea_orm(column_type = "Text")]
    pub version: String,
    pub downloads: i64,
    pub crates_io_fk: i64,
    #[sea_orm(column_type = "Text", nullable)]
    pub documentation: Option<String>,
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
    #[sea_orm(
        belongs_to = "super::cratesio_crate::Entity",
        from = "Column::CratesIoFk",
        to = "super::cratesio_crate::Column::Id",
        on_update = "NoAction",
        on_delete = "Cascade"
    )]
    CratesioCrate,
}

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

impl ActiveModelBehavior for ActiveModel {}
