use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Serialize, Deserialize)]
#[sea_orm(table_name = "supersession_events")]
pub struct Model {
#[sea_orm(primary_key)]
pub id: i64,
#[sea_orm(column_type = "Text")]
pub loser_pid: String,
#[sea_orm(column_type = "Text", nullable)]
pub winner_pid: Option<String>,
pub decided_at: DateTimeWithTimeZone,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::memories::Entity",
from = "Column::LoserPid",
to = "super::memories::Column::Pid",
on_update = "NoAction",
on_delete = "Cascade"
)]
Memories2,
#[sea_orm(
belongs_to = "super::memories::Entity",
from = "Column::WinnerPid",
to = "super::memories::Column::Pid",
on_update = "NoAction",
on_delete = "SetNull"
)]
Memories1,
}
impl ActiveModelBehavior for ActiveModel {}