//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.0

use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)]
#[sea_orm(table_name = "connection_instances")]
pub struct Model {
    #[sea_orm(primary_key)]
    pub id: i32,
    pub node_id: i32,
    #[sea_orm(unique)]
    pub instance_id: String,
    pub status: String,
    #[sea_orm(column_type = "Text")]
    pub config: String,
    pub started_at: DateTimeWithTimeZone,
    pub stopped_at: DateTimeWithTimeZone,
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
    #[sea_orm(
        belongs_to = "super::shared_nodes::Entity",
        from = "Column::NodeId",
        to = "super::shared_nodes::Column::Id",
        on_update = "Cascade",
        on_delete = "Cascade"
    )]
    SharedNodes,
}

impl Related<super::shared_nodes::Entity> for Entity {
    fn to() -> RelationDef {
        Relation::SharedNodes.def()
    }
}

impl ActiveModelBehavior for ActiveModel {}
