microsandbox_db/entity/
sandbox.rs1use sea_orm::entity::prelude::*;
4
5#[derive(Debug, Clone, Copy, PartialEq, Eq, EnumIter, DeriveActiveEnum)]
11#[sea_orm(rs_type = "String", db_type = "Text")]
12pub enum SandboxStatus {
13 #[sea_orm(string_value = "Running")]
15 Running,
16
17 #[sea_orm(string_value = "Draining")]
19 Draining,
20
21 #[sea_orm(string_value = "Paused")]
23 Paused,
24
25 #[sea_orm(string_value = "Stopped")]
27 Stopped,
28
29 #[sea_orm(string_value = "Crashed")]
31 Crashed,
32}
33
34#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
36#[sea_orm(table_name = "sandbox")]
37pub struct Model {
38 #[sea_orm(primary_key)]
39 pub id: i32,
40 #[sea_orm(unique)]
41 pub name: String,
42 pub config: String,
43 pub status: SandboxStatus,
44 pub created_at: Option<DateTime>,
45 pub updated_at: Option<DateTime>,
46}
47
48#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
54pub enum Relation {
55 #[sea_orm(has_many = "super::run::Entity")]
57 Run,
58
59 #[sea_orm(has_many = "super::sandbox_metric::Entity")]
61 SandboxMetric,
62
63 #[sea_orm(has_many = "super::snapshot::Entity")]
65 Snapshot,
66}
67
68impl Related<super::run::Entity> for Entity {
69 fn to() -> RelationDef {
70 Relation::Run.def()
71 }
72}
73
74impl Related<super::sandbox_metric::Entity> for Entity {
75 fn to() -> RelationDef {
76 Relation::SandboxMetric.def()
77 }
78}
79
80impl Related<super::snapshot::Entity> for Entity {
81 fn to() -> RelationDef {
82 Relation::Snapshot.def()
83 }
84}
85
86impl ActiveModelBehavior for ActiveModel {}