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 created_at: DateTimeWithTimeZone,
40    pub started_at: Option<DateTimeWithTimeZone>,
41    pub completed_at: Option<DateTimeWithTimeZone>,
42}
43
44#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
45pub enum Relation {
46    #[sea_orm(
47        belongs_to = "Entity",
48        from = "Column::ParentId",
49        to = "Column::Id",
50        on_update = "NoAction",
51        on_delete = "Cascade"
52    )]
53    SelfRef,
54    #[sea_orm(
55        belongs_to = "super::task_queue::Entity",
56        from = "Column::QueueName",
57        to = "super::task_queue::Column::Name",
58        on_update = "NoAction",
59        on_delete = "NoAction"
60    )]
61    TaskQueue,
62}
63
64impl Related<super::task_queue::Entity> for Entity {
65    fn to() -> RelationDef {
66        Relation::TaskQueue.def()
67    }
68}
69
70impl ActiveModelBehavior for ActiveModel {}