use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)]
#[sea_orm(table_name = "file")]
pub struct Model {
#[sea_orm(primary_key)]
pub file_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 name: String,
pub page_id: i64,
pub site_id: i64,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(has_many = "super::file_revision::Entity")]
FileRevision,
#[sea_orm(
belongs_to = "super::page::Entity",
from = "Column::PageId",
to = "super::page::Column::PageId",
on_update = "NoAction",
on_delete = "NoAction"
)]
Page,
#[sea_orm(
belongs_to = "super::site::Entity",
from = "Column::SiteId",
to = "super::site::Column::SiteId",
on_update = "NoAction",
on_delete = "NoAction"
)]
Site,
}
impl Related<super::file_revision::Entity> for Entity {
fn to() -> RelationDef {
Relation::FileRevision.def()
}
}
impl Related<super::page::Entity> for Entity {
fn to() -> RelationDef {
Relation::Page.def()
}
}
impl Related<super::site::Entity> for Entity {
fn to() -> RelationDef {
Relation::Site.def()
}
}
impl ActiveModelBehavior for ActiveModel {}