889 B · text History 2264215
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)]
#[sea_orm(table_name = "post_reactions")]
pub struct Model {
    #[sea_orm(primary_key, auto_increment = false)]
    pub id: Uuid,
    pub post_id: Uuid,
    pub user_id: Uuid,
    pub reaction_id: Uuid,
    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::reaction_types::Entity", from = "Column::ReactionId", to = "super::reaction_types::Column::Id", on_update = "Cascade", on_delete = "Cascade")]
    ReactionTypes,
}

impl ActiveModelBehavior for ActiveModel {}