Skip to main content

kellnr_entity/
webhook_queue.rs

1//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.17
2
3use sea_orm::Set;
4use sea_orm::entity::prelude::*;
5use uuid::Uuid;
6
7#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
8#[sea_orm(table_name = "webhook_queue")]
9pub struct Model {
10    #[sea_orm(primary_key, auto_increment = false)]
11    pub id: Uuid,
12    pub webhook_fk: Uuid,
13    pub payload: Json,
14    pub last_attempt: Option<DateTimeWithTimeZone>,
15    pub next_attempt: DateTimeWithTimeZone,
16}
17
18#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
19pub enum Relation {
20    #[sea_orm(
21        belongs_to = "super::webhook::Entity",
22        from = "Column::WebhookFk",
23        to = "super::webhook::Column::Id",
24        on_update = "NoAction",
25        on_delete = "Cascade"
26    )]
27    Webhook,
28}
29
30impl Related<super::webhook::Entity> for Entity {
31    fn to() -> RelationDef {
32        Relation::Webhook.def()
33    }
34}
35
36impl ActiveModelBehavior for ActiveModel {
37    fn new() -> Self {
38        Self {
39            id: Set(Uuid::new_v4()),
40            ..ActiveModelTrait::default()
41        }
42    }
43}