Skip to main content

microsandbox_db/entity/
snapshot.rs

1//! Entity definition for the `snapshot_index` table.
2//!
3//! This table is a local cache that mirrors snapshot artifacts on disk.
4//! The artifact (`snapshot.json` + upper file) is the source of truth;
5//! these rows exist for fast queries and parent-edge bookkeeping.
6
7use sea_orm::entity::prelude::*;
8
9//--------------------------------------------------------------------------------------------------
10// Types
11//--------------------------------------------------------------------------------------------------
12
13/// The snapshot-index entity model.
14#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
15#[sea_orm(table_name = "snapshot_index")]
16pub struct Model {
17    /// Descriptor digest, shared by identical artifacts in different local groups.
18    pub digest: String,
19    /// Stable opaque snapshot identity.
20    pub snapshot_id: Option<String>,
21    /// SHA-256 of canonical descriptor bytes.
22    pub descriptor_digest: Option<String>,
23    /// Convenience name, unique within its group directory.
24    pub name: Option<String>,
25    /// Local group label, absent for explicitly opened ungrouped artifacts.
26    pub group_name: Option<String>,
27    /// Absolute group directory, which scopes member aliases across storage roots.
28    pub group_path: Option<String>,
29    /// Stable identity of the parent snapshot, or NULL for a root.
30    pub parent_digest: Option<String>,
31    /// Snapshot payload scope (`disk` or `full`).
32    pub scope: String,
33    /// Closed descriptor state discriminant (`file` or `checkpoint`).
34    pub state_kind: String,
35    /// Human-readable image reference.
36    pub image_ref: String,
37    /// OCI manifest digest of the image.
38    pub image_manifest_digest: String,
39    /// On-disk format of the upper layer (`raw` or `qcow2`).
40    pub format: Option<String>,
41    /// Filesystem type inside the upper (e.g. `ext4`).
42    pub fstype: Option<String>,
43    /// Checkpoint-manifest digest for checkpoint state.
44    pub checkpoint_manifest_digest: Option<String>,
45    /// Absolute path to the artifact directory on this host.
46    #[sea_orm(primary_key, auto_increment = false)]
47    pub artifact_path: String,
48    /// Apparent size of the upper file in bytes.
49    pub size_bytes: Option<i64>,
50    /// Locality of the state closure (`embedded` or `linked`).
51    pub locality: String,
52    /// Host-local storage/provider binding identifier.
53    pub storage_binding_id: Option<String>,
54    /// Rebuildable closure availability projection.
55    pub availability: String,
56    /// Artifact migration status projection.
57    pub migration_state: String,
58    /// Stable migration failure code when blocked.
59    pub migration_error_code: Option<String>,
60    /// Snapshot creation time (from manifest).
61    pub created_at: DateTime,
62    /// When this row was inserted/refreshed.
63    pub indexed_at: DateTime,
64    /// Number of distinct child identities whose parent is this snapshot's stable identity.
65    pub child_count: i32,
66}
67
68//--------------------------------------------------------------------------------------------------
69// Types: Relations
70//--------------------------------------------------------------------------------------------------
71
72#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
73pub enum Relation {}
74
75//--------------------------------------------------------------------------------------------------
76// Trait Implementations
77//--------------------------------------------------------------------------------------------------
78
79impl ActiveModelBehavior for ActiveModel {}