Skip to main content

microsandbox_db/entity/
manifest_layer.rs

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