oxify_storage/
models.rs

1//! Database model types for SQLite
2
3use serde::{Deserialize, Serialize};
4use sqlx::FromRow;
5
6/// Database row for workflows (SQLite compatible)
7/// Note: tags is stored as JSON string, not array
8#[derive(Debug, Clone, FromRow, Serialize, Deserialize)]
9pub struct WorkflowRow {
10    pub id: String,
11    pub name: String,
12    pub description: Option<String>,
13    pub created_at: String,
14    pub updated_at: String,
15    pub version: i32,
16    pub definition: String,   // JSON string
17    pub tags: Option<String>, // JSON array string
18}
19
20/// Database row for executions (SQLite compatible)
21#[derive(Debug, Clone, FromRow)]
22pub struct ExecutionRow {
23    pub id: String,
24    pub workflow_id: String,
25    pub started_at: Option<String>,
26    pub completed_at: Option<String>,
27    pub state: String,
28    pub context: String,      // JSON string
29    pub node_results: String, // JSON string
30    pub variables: String,    // JSON string
31    pub error_message: Option<String>,
32}
33
34/// Database row for users (SQLite compatible)
35#[derive(Debug, Clone, FromRow)]
36pub struct UserRow {
37    pub id: String,
38    pub username: String,
39    pub email: String,
40    pub password_hash: String,
41    pub full_name: Option<String>,
42    pub created_at: String,
43    pub updated_at: String,
44    pub last_login: Option<String>,
45    pub is_active: bool,
46    pub is_verified: bool,
47}
48
49/// Database row for user roles
50#[derive(Debug, Clone, FromRow)]
51pub struct UserRoleRow {
52    pub user_id: String,
53    pub role: String,
54    pub granted_at: String,
55}
56
57/// Database row for user permissions
58#[derive(Debug, Clone, FromRow)]
59pub struct UserPermissionRow {
60    pub user_id: String,
61    pub permission: String,
62    pub granted_at: String,
63}