//! `SeaORM` Entity, manually maintained

use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Serialize, Deserialize)]
#[sea_orm(table_name = "worker_jobs")]
pub struct Model {
    pub created_at: DateTimeWithTimeZone,
    pub updated_at: DateTimeWithTimeZone,
    #[sea_orm(primary_key)]
    pub id: i32,
    pub parent_job_id: Option<i32>,
    pub job_kind: String,
    pub worker_name: String,
    pub display_name: Option<String>,
    pub status: String,
    pub queue_name: Option<String>,
    pub requested_by: Option<String>,
    pub requested_source: Option<String>,
    pub trigger_mode: Option<String>,
    #[sea_orm(column_type = "JsonBinary", nullable)]
    pub payload: Option<Json>,
    #[sea_orm(column_type = "JsonBinary", nullable)]
    pub result: Option<Json>,
    #[sea_orm(column_type = "Text", nullable)]
    pub error_text: Option<String>,
    #[sea_orm(column_type = "JsonBinary", nullable)]
    pub tags: Option<Json>,
    pub related_entity_type: Option<String>,
    pub related_entity_id: Option<String>,
    pub attempts_count: i32,
    pub max_attempts: i32,
    pub cancel_requested: bool,
    pub queued_at: Option<String>,
    pub started_at: Option<String>,
    pub finished_at: Option<String>,
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {}

impl ActiveModelBehavior for ActiveModel {}
