use super::sea_orm_active_enums::TaskStatus;
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)]
#[sea_orm(schema_name = "durable", table_name = "task")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: Uuid,
pub parent_id: Option<Uuid>,
pub sequence: Option<i32>,
#[sea_orm(column_type = "Text")]
pub name: String,
pub status: TaskStatus,
pub kind: String,
#[sea_orm(column_type = "JsonBinary", nullable)]
pub input: Option<Json>,
#[sea_orm(column_type = "JsonBinary", nullable)]
pub output: Option<Json>,
#[sea_orm(column_type = "Text", nullable)]
pub error: Option<String>,
pub max_retries: i32,
pub retry_count: i32,
#[sea_orm(column_type = "Text", nullable)]
pub cron: Option<String>,
pub next_run_at: Option<DateTimeWithTimeZone>,
#[sea_orm(column_type = "Text", nullable)]
pub queue_name: Option<String>,
#[sea_orm(column_type = "Text", nullable)]
pub handler: Option<String>,
#[sea_orm(column_type = "Text", nullable)]
pub executor_id: Option<String>,
#[sea_orm(column_type = "Text", nullable)]
pub app_version: Option<String>,
pub timeout_ms: Option<i64>,
pub deadline_epoch_ms: Option<i64>,
pub recovery_count: i32,
pub max_recovery_attempts: i32,
pub created_at: DateTimeWithTimeZone,
pub started_at: Option<DateTimeWithTimeZone>,
pub completed_at: Option<DateTimeWithTimeZone>,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "Entity",
from = "Column::ParentId",
to = "Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
SelfRef,
#[sea_orm(
belongs_to = "super::task_queue::Entity",
from = "Column::QueueName",
to = "super::task_queue::Column::Name",
on_update = "NoAction",
on_delete = "NoAction"
)]
TaskQueue,
}
impl Related<super::task_queue::Entity> for Entity {
fn to() -> RelationDef {
Relation::TaskQueue.def()
}
}
impl ActiveModelBehavior for ActiveModel {}