use chrono::{DateTime, Utc}; use serde::{Deserialize, Serialize}; use sqlx::FromRow; use uuid::Uuid; #[derive(Debug, Clone, Serialize, Deserialize, FromRow)] pub struct organization { pub org_id: Uuid, pub name: String, pub slug: String, pub created_at: DateTime, } #[derive(Debug, Clone, Serialize, Deserialize, FromRow)] pub struct Bot { pub bot_id: Uuid, pub name: String, pub status: BotStatus, pub config: serde_json::Value, pub created_at: chrono::DateTime, pub updated_at: chrono::DateTime, } #[derive(Debug, Clone, Serialize, Deserialize, sqlx::Type)] #[serde(rename_all = "snake_case")] #[sqlx(type_name = "bot_status", rename_all = "snake_case")] pub enum BotStatus { Active, Inactive, Maintenance, } use chrono::{DateTime, Utc}; use serde::{Deserialize, Serialize}; use sqlx::FromRow; use uuid::Uuid; #[derive(Debug, Clone, Copy, PartialEq)] pub enum TriggerKind { Scheduled = 0, TableUpdate = 1, TableInsert = 2, TableDelete = 3, } impl TriggerKind { pub fn from_i32(value: i32) -> Option { match value { 0 => Some(Self::Scheduled), 1 => Some(Self::TableUpdate), 2 => Some(Self::TableInsert), 3 => Some(Self::TableDelete), _ => None, } } } #[derive(Debug, FromRow, Serialize, Deserialize)] pub struct Automation { pub id: Uuid, pub kind: i32, // Using number for trigger type pub target: Option, pub schedule: Option, pub param: String, pub is_active: bool, pub last_triggered: Option>, }