use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "source")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: Uuid,
pub parent_directory: Uuid,
pub informant: i8,
pub informant_parameters: Json,
pub network: i8,
pub network_parameters: Option<Json>,
#[sea_orm(column_type = "Text")]
pub name: String,
#[sea_orm(column_type = "Text", nullable)]
pub description: Option<String>,
#[sea_orm(column_type = "Text", nullable)]
pub icon_uri: Option<String>,
#[sea_orm(column_type = "Text", nullable)]
pub logo_uri: Option<String>,
#[sea_orm(column_type = "Text", nullable, unique)]
pub custom_id: Option<String>,
pub is_enabled: bool,
pub provided_ttl: Option<i32>,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(has_many = "super::news::Entity")]
News,
#[sea_orm(
belongs_to = "super::source_directory::Entity",
from = "Column::ParentDirectory",
to = "super::source_directory::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
SourceDirectory,
#[sea_orm(has_many = "super::source_fetch_signal::Entity")]
SourceFetchSignal,
#[sea_orm(has_many = "super::source_to_category_link::Entity")]
SourceToCategoryLink,
}
impl Related<super::news::Entity> for Entity {
fn to() -> RelationDef {
Relation::News.def()
}
}
impl Related<super::source_directory::Entity> for Entity {
fn to() -> RelationDef {
Relation::SourceDirectory.def()
}
}
impl Related<super::source_fetch_signal::Entity> for Entity {
fn to() -> RelationDef {
Relation::SourceFetchSignal.def()
}
}
impl Related<super::source_to_category_link::Entity> for Entity {
fn to() -> RelationDef {
Relation::SourceToCategoryLink.def()
}
}
impl Related<super::source_category::Entity> for Entity {
fn to() -> RelationDef {
super::source_to_category_link::Relation::SourceCategory.def()
}
fn via() -> Option<RelationDef> {
Some(super::source_to_category_link::Relation::Source.def().rev())
}
}
impl ActiveModelBehavior for ActiveModel {}