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