Skip to main content

chronon_core/models/
revision.rs

1//! Job revision model - represents a snapshot of job configuration changes.
2
3use chrono::{DateTime, Utc};
4use serde::{Deserialize, Serialize};
5use serde_json::Value;
6
7/// A revision of a job's configuration.
8///
9/// Every configuration change creates a new revision for audit purposes.
10#[derive(Debug, Clone, Serialize, Deserialize)]
11pub struct JobRevision {
12    /// Unique identifier (UUID).
13    pub revision_id: String,
14
15    /// Job this revision belongs to.
16    pub job_id: String,
17
18    /// Sequential revision number (1, 2, 3...).
19    pub revision_number: i32,
20
21    /// When this revision was created.
22    pub changed_at: DateTime<Utc>,
23
24    /// Who made this change (serialized Actor).
25    pub changed_by_actor_json: Value,
26
27    /// Full snapshot of the job configuration at this revision.
28    pub snapshot_json: Value,
29}
30
31impl JobRevision {
32    /// Create a new revision for a job.
33    pub fn new(
34        job_id: impl Into<String>,
35        revision_number: i32,
36        changed_by_actor_json: Value,
37        snapshot_json: Value,
38    ) -> Self {
39        Self {
40            revision_id: uuid::Uuid::new_v4().to_string(),
41            job_id: job_id.into(),
42            revision_number,
43            changed_at: Utc::now(),
44            changed_by_actor_json,
45            snapshot_json,
46        }
47    }
48}