Skip to main content

durable_db/entity/
task.rs

1//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.19
2
3use super::sea_orm_active_enums::TaskStatus;
4use sea_orm::entity::prelude::*;
5use serde::{Deserialize, Serialize};
6
7#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)]
8#[sea_orm(schema_name = "durable", table_name = "task")]
9pub struct Model {
10    #[sea_orm(primary_key, auto_increment = false)]
11    pub id: Uuid,
12    pub parent_id: Option<Uuid>,
13    pub sequence: Option<i32>,
14    #[sea_orm(column_type = "Text")]
15    pub name: String,
16    pub status: TaskStatus,
17    pub kind: String,
18    #[sea_orm(column_type = "JsonBinary", nullable)]
19    pub input: Option<Json>,
20    #[sea_orm(column_type = "JsonBinary", nullable)]
21    pub output: Option<Json>,
22    #[sea_orm(column_type = "Text", nullable)]
23    pub error: Option<String>,
24    pub max_retries: i32,
25    pub retry_count: i32,
26    #[sea_orm(column_type = "Text", nullable)]
27    pub cron: Option<String>,
28    pub next_run_at: Option<DateTimeWithTimeZone>,
29    #[sea_orm(column_type = "Text", nullable)]
30    pub queue_name: Option<String>,
31    #[sea_orm(column_type = "Text", nullable)]
32    pub handler: Option<String>,
33    #[sea_orm(column_type = "Text", nullable)]
34    pub executor_id: Option<String>,
35    #[sea_orm(column_type = "Text", nullable)]
36    pub app_version: Option<String>,
37    pub timeout_ms: Option<i64>,
38    pub deadline_epoch_ms: Option<i64>,
39    pub recovery_count: i32,
40    pub max_recovery_attempts: i32,
41    pub created_at: DateTimeWithTimeZone,
42    pub started_at: Option<DateTimeWithTimeZone>,
43    pub completed_at: Option<DateTimeWithTimeZone>,
44}
45
46#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
47pub enum Relation {
48    #[sea_orm(
49        belongs_to = "Entity",
50        from = "Column::ParentId",
51        to = "Column::Id",
52        on_update = "NoAction",
53        on_delete = "Cascade"
54    )]
55    SelfRef,
56    #[sea_orm(
57        belongs_to = "super::task_queue::Entity",
58        from = "Column::QueueName",
59        to = "super::task_queue::Column::Name",
60        on_update = "NoAction",
61        on_delete = "NoAction"
62    )]
63    TaskQueue,
64}
65
66impl Related<super::task_queue::Entity> for Entity {
67    fn to() -> RelationDef {
68        Relation::TaskQueue.def()
69    }
70}
71
72impl ActiveModelBehavior for ActiveModel {}