use sea_orm::entity::prelude::*;
#[derive(Debug, Clone, Copy, PartialEq, Eq, EnumIter, DeriveActiveEnum)]
#[sea_orm(rs_type = "String", db_type = "Text")]
pub enum SandboxStatus {
#[sea_orm(string_value = "Running")]
Running,
#[sea_orm(string_value = "Draining")]
Draining,
#[sea_orm(string_value = "Paused")]
Paused,
#[sea_orm(string_value = "Stopped")]
Stopped,
#[sea_orm(string_value = "Crashed")]
Crashed,
}
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
#[sea_orm(table_name = "sandbox")]
pub struct Model {
#[sea_orm(primary_key)]
pub id: i32,
#[sea_orm(unique)]
pub name: String,
pub config: String,
pub status: SandboxStatus,
pub created_at: Option<DateTime>,
pub updated_at: Option<DateTime>,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(has_many = "super::run::Entity")]
Run,
#[sea_orm(has_many = "super::sandbox_metric::Entity")]
SandboxMetric,
#[sea_orm(has_many = "super::snapshot::Entity")]
Snapshot,
}
impl Related<super::run::Entity> for Entity {
fn to() -> RelationDef {
Relation::Run.def()
}
}
impl Related<super::sandbox_metric::Entity> for Entity {
fn to() -> RelationDef {
Relation::SandboxMetric.def()
}
}
impl Related<super::snapshot::Entity> for Entity {
fn to() -> RelationDef {
Relation::Snapshot.def()
}
}
impl ActiveModelBehavior for ActiveModel {}