use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "host")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: String,
pub name: String,
pub network: String,
pub role: String,
pub ip: String,
pub listen_port: i32,
pub is_lighthouse: bool,
pub is_relay: bool,
pub counter: i32,
pub created_at: i64,
pub is_blocked: bool,
pub last_seen_at: i64,
pub last_version: i32,
pub last_platform: String,
pub last_out_of_date: bool,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(has_many = "super::host_config_override::Entity")]
HostConfigOverride,
#[sea_orm(has_many = "super::host_enrollment_code::Entity")]
HostEnrollmentCode,
#[sea_orm(has_many = "super::host_static_address::Entity")]
HostStaticAddress,
#[sea_orm(has_many = "super::keystore_entry::Entity")]
KeystoreEntry,
#[sea_orm(
belongs_to = "super::network::Entity",
from = "Column::Network",
to = "super::network::Column::Id",
on_update = "Cascade",
on_delete = "Cascade"
)]
Network,
#[sea_orm(
belongs_to = "super::role::Entity",
from = "Column::Role",
to = "super::role::Column::Id",
on_update = "Cascade",
on_delete = "Cascade"
)]
Role,
}
impl Related<super::host_config_override::Entity> for Entity {
fn to() -> RelationDef {
Relation::HostConfigOverride.def()
}
}
impl Related<super::host_enrollment_code::Entity> for Entity {
fn to() -> RelationDef {
Relation::HostEnrollmentCode.def()
}
}
impl Related<super::host_static_address::Entity> for Entity {
fn to() -> RelationDef {
Relation::HostStaticAddress.def()
}
}
impl Related<super::keystore_entry::Entity> for Entity {
fn to() -> RelationDef {
Relation::KeystoreEntry.def()
}
}
impl Related<super::network::Entity> for Entity {
fn to() -> RelationDef {
Relation::Network.def()
}
}
impl Related<super::role::Entity> for Entity {
fn to() -> RelationDef {
Relation::Role.def()
}
}
impl ActiveModelBehavior for ActiveModel {}