use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)]
#[sea_orm(table_name = "post_revisions")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: Uuid,
pub post_id: Uuid,
/// Who authored this version (None if that user was later deleted).
pub editor_id: Option<Uuid>,
/// 1-based; revision 1 is the original.
pub revision_number: i32,
#[sea_orm(column_type = "Text")]
pub raw: String,
#[sea_orm(column_type = "Text")]
pub cooked: String,
pub created_at: DateTimeWithTimeZone,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::posts::Entity",
from = "Column::PostId",
to = "super::posts::Column::Id",
on_update = "Cascade",
on_delete = "Cascade"
)]
Posts,
#[sea_orm(
belongs_to = "super::users::Entity",
from = "Column::EditorId",
to = "super::users::Column::Id",
on_update = "Cascade",
on_delete = "SetNull"
)]
Users,
}
impl Related<super::posts::Entity> for Entity {
fn to() -> RelationDef {
Relation::Posts.def()
}
}
impl Related<super::users::Entity> for Entity {
fn to() -> RelationDef {
Relation::Users.def()
}
}
impl ActiveModelBehavior for ActiveModel {}
neiam
/recourse
public · Issues · Pulls · Labels · Forks · Compare · Actions running · Badges · Packages
⭐
Log in to mark this repository.
1.4 KiB · text
History
2264215