use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "source_directory")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: Uuid,
pub parent_directory: Option<Uuid>,
#[sea_orm(column_type = "Text", unique)]
pub name: String,
#[sea_orm(column_type = "Text", nullable)]
pub description: Option<String>,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(has_many = "super::source::Entity")]
Source,
#[sea_orm(
belongs_to = "Entity",
from = "Column::ParentDirectory",
to = "Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
SelfRef,
}
impl Related<super::source::Entity> for Entity {
fn to() -> RelationDef {
Relation::Source.def()
}
}
impl ActiveModelBehavior for ActiveModel {}