deepwell 2024.5.12

DEEPWELL - Wikijump API provider and database manager
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.14

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

#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)]
#[sea_orm(table_name = "site")]
pub struct Model {
    #[sea_orm(primary_key)]
    pub site_id: i64,
    pub created_at: TimeDateTimeWithTimeZone,
    pub updated_at: Option<TimeDateTimeWithTimeZone>,
    pub deleted_at: Option<TimeDateTimeWithTimeZone>,
    pub from_wikidot: bool,
    #[sea_orm(column_type = "Text")]
    pub slug: String,
    #[sea_orm(column_type = "Text")]
    pub name: String,
    #[sea_orm(column_type = "Text")]
    pub tagline: String,
    #[sea_orm(column_type = "Text")]
    pub description: String,
    #[sea_orm(column_type = "Text")]
    pub locale: String,
    #[sea_orm(column_type = "Text")]
    pub default_page: String,
    #[sea_orm(column_type = "Text", nullable)]
    pub custom_domain: Option<String>,
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
    #[sea_orm(has_many = "super::file::Entity")]
    File,
    #[sea_orm(has_many = "super::file_revision::Entity")]
    FileRevision,
    #[sea_orm(has_many = "super::filter::Entity")]
    Filter,
    #[sea_orm(has_many = "super::message_report::Entity")]
    MessageReport,
    #[sea_orm(has_many = "super::page::Entity")]
    Page,
    #[sea_orm(has_many = "super::page_category::Entity")]
    PageCategory,
    #[sea_orm(has_many = "super::page_revision::Entity")]
    PageRevision,
    #[sea_orm(
        belongs_to = "super::site_domain::Entity",
        from = "Column::CustomDomain",
        to = "super::site_domain::Column::Domain",
        on_update = "NoAction",
        on_delete = "NoAction"
    )]
    SiteDomain,
}

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

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

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

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

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

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

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

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

impl Related<super::message::Entity> for Entity {
    fn to() -> RelationDef {
        super::message_report::Relation::Message.def()
    }
    fn via() -> Option<RelationDef> {
        Some(super::message_report::Relation::Site.def().rev())
    }
}

impl ActiveModelBehavior for ActiveModel {}