microsandbox_db/entity/
manifest.rs1use sea_orm::entity::prelude::*;
4
5#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
11#[sea_orm(table_name = "manifest")]
12pub struct Model {
13 #[sea_orm(primary_key)]
14 pub id: i32,
15 pub image_id: i32,
16 pub index_id: Option<i32>,
17 #[sea_orm(unique)]
18 pub digest: String,
19 pub schema_version: Option<i32>,
20 pub media_type: Option<String>,
21 pub annotations: Option<String>,
22 pub created_at: Option<DateTime>,
23}
24
25#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
31pub enum Relation {
32 #[sea_orm(
34 belongs_to = "super::image::Entity",
35 from = "Column::ImageId",
36 to = "super::image::Column::Id",
37 on_delete = "Cascade"
38 )]
39 Image,
40
41 #[sea_orm(
43 belongs_to = "super::index::Entity",
44 from = "Column::IndexId",
45 to = "super::index::Column::Id",
46 on_delete = "SetNull"
47 )]
48 Index,
49
50 #[sea_orm(has_one = "super::config::Entity")]
52 Config,
53
54 #[sea_orm(has_many = "super::manifest_layer::Entity")]
56 ManifestLayer,
57}
58
59impl Related<super::image::Entity> for Entity {
60 fn to() -> RelationDef {
61 Relation::Image.def()
62 }
63}
64
65impl Related<super::index::Entity> for Entity {
66 fn to() -> RelationDef {
67 Relation::Index.def()
68 }
69}
70
71impl Related<super::config::Entity> for Entity {
72 fn to() -> RelationDef {
73 Relation::Config.def()
74 }
75}
76
77impl Related<super::manifest_layer::Entity> for Entity {
78 fn to() -> RelationDef {
79 Relation::ManifestLayer.def()
80 }
81}
82
83impl Related<super::layer::Entity> for Entity {
84 fn to() -> RelationDef {
85 super::manifest_layer::Relation::Layer.def()
86 }
87
88 fn via() -> Option<RelationDef> {
89 Some(super::manifest_layer::Relation::Manifest.def().rev())
90 }
91}
92
93impl ActiveModelBehavior for ActiveModel {}