Skip to main content

microsandbox_db/entity/
config.rs

1//! Entity definition for the `config` 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 env: Option<String>,
19    pub cmd: Option<String>,
20    pub entrypoint: Option<String>,
21    pub working_dir: Option<String>,
22    pub user: Option<String>,
23    pub labels: Option<String>,
24    pub stop_signal: Option<String>,
25    pub created_at: Option<DateTime>,
26}
27
28//--------------------------------------------------------------------------------------------------
29// Types: Relations
30//--------------------------------------------------------------------------------------------------
31
32/// Relations for the config entity.
33#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
34pub enum Relation {
35    /// A config belongs to a manifest (1:1).
36    #[sea_orm(
37        belongs_to = "super::manifest::Entity",
38        from = "Column::ManifestId",
39        to = "super::manifest::Column::Id",
40        on_delete = "Cascade"
41    )]
42    Manifest,
43}
44
45impl Related<super::manifest::Entity> for Entity {
46    fn to() -> RelationDef {
47        Relation::Manifest.def()
48    }
49}
50
51//--------------------------------------------------------------------------------------------------
52// Trait Implementations
53//--------------------------------------------------------------------------------------------------
54
55impl ActiveModelBehavior for ActiveModel {}