Skip to main content

microsandbox_db/entity/
config.rs

1//! Entity definition for the `configs` table.
2
3use sea_orm::entity::prelude::*;
4
5//--------------------------------------------------------------------------------------------------
6// Types
7//--------------------------------------------------------------------------------------------------
8
9/// The OCI image config entity model.
10#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
11#[sea_orm(table_name = "config")]
12pub struct Model {
13    #[sea_orm(primary_key)]
14    pub id: i32,
15    #[sea_orm(unique)]
16    pub manifest_id: i32,
17    pub digest: String,
18    pub architecture: Option<String>,
19    pub os: Option<String>,
20    pub os_variant: Option<String>,
21    pub env: Option<String>,
22    pub cmd: Option<String>,
23    pub entrypoint: Option<String>,
24    pub working_dir: Option<String>,
25    pub volumes: Option<String>,
26    pub exposed_ports: Option<String>,
27    pub user: Option<String>,
28    pub rootfs_type: Option<String>,
29    pub rootfs_diff_ids: Option<String>,
30    pub history: Option<String>,
31    pub created_at: Option<DateTime>,
32}
33
34//--------------------------------------------------------------------------------------------------
35// Types: Relations
36//--------------------------------------------------------------------------------------------------
37
38/// Relations for the config entity.
39#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
40pub enum Relation {
41    /// A config belongs to a manifest (1:1).
42    #[sea_orm(
43        belongs_to = "super::manifest::Entity",
44        from = "Column::ManifestId",
45        to = "super::manifest::Column::Id",
46        on_delete = "Cascade"
47    )]
48    Manifest,
49}
50
51impl Related<super::manifest::Entity> for Entity {
52    fn to() -> RelationDef {
53        Relation::Manifest.def()
54    }
55}
56
57//--------------------------------------------------------------------------------------------------
58// Trait Implementations
59//--------------------------------------------------------------------------------------------------
60
61impl ActiveModelBehavior for ActiveModel {}