feat: add new database entities and migration for proxy configuration

- Introduced `log_setting`, `proxy_config`, `proxy_setting`, `rewrite_rule`, `server_block`, `ssl_certificate`, and `upstream` entities with their respective fields and relationships.
- Updated `mod.rs` and `prelude.rs` to include new entities.
- Created migration script to set up new tables and relationships in the database.
- Altered existing `agents` table to include a foreign key reference to `agent_group`.
This commit is contained in:
GW_MC
2026-06-21 11:06:20 +00:00
parent be1d2e3fa9
commit 2dbab85c87
20 changed files with 1742 additions and 1 deletions

View File

@@ -0,0 +1,61 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 2.0
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Serialize, Deserialize)]
#[sea_orm(table_name = "access_rule")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: Uuid,
pub server_id: Option<Uuid>,
pub location_id: Option<Uuid>,
pub r#type: String,
pub ip_cidr: String,
pub description: Option<String>,
pub priority: i32,
pub is_deleted: bool,
pub override_of_id: Option<Uuid>,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "Entity",
from = "Column::OverrideOfId",
to = "Column::Id",
on_update = "Cascade",
on_delete = "SetNull"
)]
SelfRef,
#[sea_orm(
belongs_to = "super::location_block::Entity",
from = "Column::LocationId",
to = "super::location_block::Column::Id",
on_update = "Cascade",
on_delete = "Cascade"
)]
LocationBlock,
#[sea_orm(
belongs_to = "super::server_block::Entity",
from = "Column::ServerId",
to = "super::server_block::Column::Id",
on_update = "Cascade",
on_delete = "Cascade"
)]
ServerBlock,
}
impl Related<super::location_block::Entity> for Entity {
fn to() -> RelationDef {
Relation::LocationBlock.def()
}
}
impl Related<super::server_block::Entity> for Entity {
fn to() -> RelationDef {
Relation::ServerBlock.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@@ -0,0 +1,64 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 2.0
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Serialize, Deserialize)]
#[sea_orm(table_name = "agent_config_binding")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: Uuid,
pub agent_id: Option<Uuid>,
pub group_id: Option<Uuid>,
pub config_id: Uuid,
pub is_active: bool,
pub applied_at: DateTime,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::agent_group::Entity",
from = "Column::GroupId",
to = "super::agent_group::Column::Id",
on_update = "Cascade",
on_delete = "Cascade"
)]
AgentGroup,
#[sea_orm(
belongs_to = "super::agents::Entity",
from = "Column::AgentId",
to = "super::agents::Column::Id",
on_update = "Cascade",
on_delete = "Cascade"
)]
Agents,
#[sea_orm(
belongs_to = "super::proxy_config::Entity",
from = "Column::ConfigId",
to = "super::proxy_config::Column::Id",
on_update = "Cascade",
on_delete = "Cascade"
)]
ProxyConfig,
}
impl Related<super::agent_group::Entity> for Entity {
fn to() -> RelationDef {
Relation::AgentGroup.def()
}
}
impl Related<super::agents::Entity> for Entity {
fn to() -> RelationDef {
Relation::Agents.def()
}
}
impl Related<super::proxy_config::Entity> for Entity {
fn to() -> RelationDef {
Relation::ProxyConfig.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@@ -0,0 +1,35 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 2.0
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Serialize, Deserialize)]
#[sea_orm(table_name = "agent_group")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: Uuid,
pub name: String,
pub description: Option<String>,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(has_many = "super::agent_config_binding::Entity")]
AgentConfigBinding,
#[sea_orm(has_many = "super::agents::Entity")]
Agents,
}
impl Related<super::agent_config_binding::Entity> for Entity {
fn to() -> RelationDef {
Relation::AgentConfigBinding.def()
}
}
impl Related<super::agents::Entity> for Entity {
fn to() -> RelationDef {
Relation::Agents.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@@ -19,9 +19,33 @@ pub struct Model {
pub labels: Option<Json>,
pub created_at: DateTimeWithTimeZone,
pub updated_at: DateTimeWithTimeZone,
pub group_id: Option<Uuid>,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {}
pub enum Relation {
#[sea_orm(has_many = "super::agent_config_binding::Entity")]
AgentConfigBinding,
#[sea_orm(
belongs_to = "super::agent_group::Entity",
from = "Column::GroupId",
to = "super::agent_group::Column::Id",
on_update = "Cascade",
on_delete = "SetNull"
)]
AgentGroup,
}
impl Related<super::agent_config_binding::Entity> for Entity {
fn to() -> RelationDef {
Relation::AgentConfigBinding.def()
}
}
impl Related<super::agent_group::Entity> for Entity {
fn to() -> RelationDef {
Relation::AgentGroup.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@@ -0,0 +1,37 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 2.0
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Serialize, Deserialize)]
#[sea_orm(table_name = "cache_zone")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: Uuid,
pub name: String,
pub path: String,
pub size_limit: String,
pub override_of_id: Option<Uuid>,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "Entity",
from = "Column::OverrideOfId",
to = "Column::Id",
on_update = "Cascade",
on_delete = "SetNull"
)]
SelfRef,
#[sea_orm(has_many = "super::proxy_setting::Entity")]
ProxySetting,
}
impl Related<super::proxy_setting::Entity> for Entity {
fn to() -> RelationDef {
Relation::ProxySetting.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@@ -0,0 +1,37 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 2.0
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Serialize, Deserialize)]
#[sea_orm(table_name = "config_inheritance")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: Uuid,
pub child_config_id: Uuid,
pub parent_config_id: Uuid,
pub priority: Option<i32>,
pub applied_at: DateTime,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::proxy_config::Entity",
from = "Column::ChildConfigId",
to = "super::proxy_config::Column::Id",
on_update = "Cascade",
on_delete = "Cascade"
)]
ProxyConfig2,
#[sea_orm(
belongs_to = "super::proxy_config::Entity",
from = "Column::ParentConfigId",
to = "super::proxy_config::Column::Id",
on_update = "Cascade",
on_delete = "Cascade"
)]
ProxyConfig1,
}
impl ActiveModelBehavior for ActiveModel {}

View File

@@ -0,0 +1,59 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 2.0
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Serialize, Deserialize)]
#[sea_orm(table_name = "limit_rule")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: Uuid,
pub location_id: Uuid,
pub zone_id: Uuid,
pub burst: Option<i32>,
pub nodelay: Option<bool>,
pub is_deleted: bool,
pub override_of_id: Option<Uuid>,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "Entity",
from = "Column::OverrideOfId",
to = "Column::Id",
on_update = "Cascade",
on_delete = "SetNull"
)]
SelfRef,
#[sea_orm(
belongs_to = "super::limit_zone::Entity",
from = "Column::ZoneId",
to = "super::limit_zone::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
LimitZone,
#[sea_orm(
belongs_to = "super::location_block::Entity",
from = "Column::LocationId",
to = "super::location_block::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
LocationBlock,
}
impl Related<super::limit_zone::Entity> for Entity {
fn to() -> RelationDef {
Relation::LimitZone.def()
}
}
impl Related<super::location_block::Entity> for Entity {
fn to() -> RelationDef {
Relation::LocationBlock.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@@ -0,0 +1,37 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 2.0
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Serialize, Deserialize)]
#[sea_orm(table_name = "limit_zone")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: Uuid,
pub name: String,
pub key: String,
pub rate: String,
pub override_of_id: Option<Uuid>,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(has_many = "super::limit_rule::Entity")]
LimitRule,
#[sea_orm(
belongs_to = "Entity",
from = "Column::OverrideOfId",
to = "Column::Id",
on_update = "Cascade",
on_delete = "SetNull"
)]
SelfRef,
}
impl Related<super::limit_rule::Entity> for Entity {
fn to() -> RelationDef {
Relation::LimitRule.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@@ -0,0 +1,91 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 2.0
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Serialize, Deserialize)]
#[sea_orm(table_name = "location_block")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: Uuid,
pub server_id: Uuid,
pub path_pattern: String,
pub proxy_pass_upstream_id: Option<Uuid>,
#[sea_orm(column_type = "JsonBinary", nullable)]
pub metadata: Option<Json>,
pub override_of_id: Option<Uuid>,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(has_many = "super::access_rule::Entity")]
AccessRule,
#[sea_orm(has_many = "super::limit_rule::Entity")]
LimitRule,
#[sea_orm(
belongs_to = "Entity",
from = "Column::OverrideOfId",
to = "Column::Id",
on_update = "Cascade",
on_delete = "SetNull"
)]
SelfRef,
#[sea_orm(has_many = "super::proxy_setting::Entity")]
ProxySetting,
#[sea_orm(has_many = "super::rewrite_rule::Entity")]
RewriteRule,
#[sea_orm(
belongs_to = "super::server_block::Entity",
from = "Column::ServerId",
to = "super::server_block::Column::Id",
on_update = "Cascade",
on_delete = "Cascade"
)]
ServerBlock,
#[sea_orm(
belongs_to = "super::upstream::Entity",
from = "Column::ProxyPassUpstreamId",
to = "super::upstream::Column::Id",
on_update = "Cascade",
on_delete = "SetNull"
)]
Upstream,
}
impl Related<super::access_rule::Entity> for Entity {
fn to() -> RelationDef {
Relation::AccessRule.def()
}
}
impl Related<super::limit_rule::Entity> for Entity {
fn to() -> RelationDef {
Relation::LimitRule.def()
}
}
impl Related<super::proxy_setting::Entity> for Entity {
fn to() -> RelationDef {
Relation::ProxySetting.def()
}
}
impl Related<super::rewrite_rule::Entity> for Entity {
fn to() -> RelationDef {
Relation::RewriteRule.def()
}
}
impl Related<super::server_block::Entity> for Entity {
fn to() -> RelationDef {
Relation::ServerBlock.def()
}
}
impl Related<super::upstream::Entity> for Entity {
fn to() -> RelationDef {
Relation::Upstream.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@@ -0,0 +1,44 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 2.0
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Serialize, Deserialize)]
#[sea_orm(table_name = "log_setting")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: Uuid,
pub server_id: Uuid,
pub access_log_path: Option<String>,
pub error_log_path: Option<String>,
pub log_level: Option<String>,
pub override_of_id: Option<Uuid>,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "Entity",
from = "Column::OverrideOfId",
to = "Column::Id",
on_update = "Cascade",
on_delete = "SetNull"
)]
SelfRef,
#[sea_orm(
belongs_to = "super::server_block::Entity",
from = "Column::ServerId",
to = "super::server_block::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
ServerBlock,
}
impl Related<super::server_block::Entity> for Entity {
fn to() -> RelationDef {
Relation::ServerBlock.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@@ -2,5 +2,20 @@
pub mod prelude;
pub mod access_rule;
pub mod agent_config_binding;
pub mod agent_group;
pub mod agents;
pub mod cache_zone;
pub mod config_inheritance;
pub mod limit_rule;
pub mod limit_zone;
pub mod location_block;
pub mod log_setting;
pub mod proxy_config;
pub mod proxy_setting;
pub mod public_key_revocations;
pub mod rewrite_rule;
pub mod server_block;
pub mod ssl_certificate;
pub mod upstream;

View File

@@ -1,4 +1,19 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 2.0
pub use super::access_rule::Entity as AccessRule;
pub use super::agent_config_binding::Entity as AgentConfigBinding;
pub use super::agent_group::Entity as AgentGroup;
pub use super::agents::Entity as Agents;
pub use super::cache_zone::Entity as CacheZone;
pub use super::config_inheritance::Entity as ConfigInheritance;
pub use super::limit_rule::Entity as LimitRule;
pub use super::limit_zone::Entity as LimitZone;
pub use super::location_block::Entity as LocationBlock;
pub use super::log_setting::Entity as LogSetting;
pub use super::proxy_config::Entity as ProxyConfig;
pub use super::proxy_setting::Entity as ProxySetting;
pub use super::public_key_revocations::Entity as PublicKeyRevocations;
pub use super::rewrite_rule::Entity as RewriteRule;
pub use super::server_block::Entity as ServerBlock;
pub use super::ssl_certificate::Entity as SslCertificate;
pub use super::upstream::Entity as Upstream;

View File

@@ -0,0 +1,46 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 2.0
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Serialize, Deserialize)]
#[sea_orm(table_name = "proxy_config")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: Uuid,
pub name: String,
pub description: Option<String>,
pub is_template: bool,
pub created_at: DateTime,
pub updated_at: DateTime,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(has_many = "super::agent_config_binding::Entity")]
AgentConfigBinding,
#[sea_orm(has_many = "super::server_block::Entity")]
ServerBlock,
#[sea_orm(has_many = "super::upstream::Entity")]
Upstream,
}
impl Related<super::agent_config_binding::Entity> for Entity {
fn to() -> RelationDef {
Relation::AgentConfigBinding.def()
}
}
impl Related<super::server_block::Entity> for Entity {
fn to() -> RelationDef {
Relation::ServerBlock.def()
}
}
impl Related<super::upstream::Entity> for Entity {
fn to() -> RelationDef {
Relation::Upstream.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@@ -0,0 +1,60 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 2.0
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Serialize, Deserialize)]
#[sea_orm(table_name = "proxy_setting")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: Uuid,
pub location_id: Uuid,
pub read_timeout: Option<i32>,
pub connect_timeout: Option<i32>,
pub buffer_size: Option<i32>,
pub cache_enabled: Option<bool>,
pub cache_zone: Option<Uuid>,
pub override_of_id: Option<Uuid>,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::cache_zone::Entity",
from = "Column::CacheZone",
to = "super::cache_zone::Column::Id",
on_update = "NoAction",
on_delete = "SetNull"
)]
CacheZone,
#[sea_orm(
belongs_to = "super::location_block::Entity",
from = "Column::LocationId",
to = "super::location_block::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
LocationBlock,
#[sea_orm(
belongs_to = "Entity",
from = "Column::OverrideOfId",
to = "Column::Id",
on_update = "Cascade",
on_delete = "SetNull"
)]
SelfRef,
}
impl Related<super::cache_zone::Entity> for Entity {
fn to() -> RelationDef {
Relation::CacheZone.def()
}
}
impl Related<super::location_block::Entity> for Entity {
fn to() -> RelationDef {
Relation::LocationBlock.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@@ -0,0 +1,46 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 2.0
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Serialize, Deserialize)]
#[sea_orm(table_name = "rewrite_rule")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: Uuid,
pub location_id: Uuid,
pub pattern: String,
pub replacement: String,
pub flag: Option<String>,
pub priority: i32,
pub is_deleted: bool,
pub override_of_id: Option<Uuid>,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::location_block::Entity",
from = "Column::LocationId",
to = "super::location_block::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
LocationBlock,
#[sea_orm(
belongs_to = "Entity",
from = "Column::OverrideOfId",
to = "Column::Id",
on_update = "Cascade",
on_delete = "SetNull"
)]
SelfRef,
}
impl Related<super::location_block::Entity> for Entity {
fn to() -> RelationDef {
Relation::LocationBlock.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@@ -0,0 +1,83 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 2.0
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Serialize, Deserialize)]
#[sea_orm(table_name = "server_block")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: Uuid,
pub config_id: Uuid,
pub server_name: Option<Vec<String>>,
pub listen_port: i32,
pub ssl_enabled: Option<bool>,
pub ssl_cert_id: Option<Uuid>,
pub override_of_id: Option<Uuid>,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(has_many = "super::access_rule::Entity")]
AccessRule,
#[sea_orm(has_many = "super::location_block::Entity")]
LocationBlock,
#[sea_orm(has_many = "super::log_setting::Entity")]
LogSetting,
#[sea_orm(
belongs_to = "super::proxy_config::Entity",
from = "Column::ConfigId",
to = "super::proxy_config::Column::Id",
on_update = "Cascade",
on_delete = "Cascade"
)]
ProxyConfig,
#[sea_orm(
belongs_to = "Entity",
from = "Column::OverrideOfId",
to = "Column::Id",
on_update = "Cascade",
on_delete = "SetNull"
)]
SelfRef,
#[sea_orm(
belongs_to = "super::ssl_certificate::Entity",
from = "Column::SslCertId",
to = "super::ssl_certificate::Column::Id",
on_update = "Cascade",
on_delete = "SetNull"
)]
SslCertificate,
}
impl Related<super::access_rule::Entity> for Entity {
fn to() -> RelationDef {
Relation::AccessRule.def()
}
}
impl Related<super::location_block::Entity> for Entity {
fn to() -> RelationDef {
Relation::LocationBlock.def()
}
}
impl Related<super::log_setting::Entity> for Entity {
fn to() -> RelationDef {
Relation::LogSetting.def()
}
}
impl Related<super::proxy_config::Entity> for Entity {
fn to() -> RelationDef {
Relation::ProxyConfig.def()
}
}
impl Related<super::ssl_certificate::Entity> for Entity {
fn to() -> RelationDef {
Relation::SslCertificate.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@@ -0,0 +1,29 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 2.0
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Serialize, Deserialize)]
#[sea_orm(table_name = "ssl_certificate")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: Uuid,
pub name: String,
pub cert_path: String,
pub key_path: String,
pub expiry_date: DateTime,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(has_many = "super::server_block::Entity")]
ServerBlock,
}
impl Related<super::server_block::Entity> for Entity {
fn to() -> RelationDef {
Relation::ServerBlock.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@@ -0,0 +1,54 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 2.0
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Serialize, Deserialize)]
#[sea_orm(table_name = "upstream")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: Uuid,
pub config_id: Uuid,
pub name: String,
pub target_host: String,
pub target_port: i32,
#[sea_orm(column_type = "JsonBinary", nullable)]
pub metadata: Option<Json>,
pub override_of_id: Option<Uuid>,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(has_many = "super::location_block::Entity")]
LocationBlock,
#[sea_orm(
belongs_to = "super::proxy_config::Entity",
from = "Column::ConfigId",
to = "super::proxy_config::Column::Id",
on_update = "Cascade",
on_delete = "Cascade"
)]
ProxyConfig,
#[sea_orm(
belongs_to = "Entity",
from = "Column::OverrideOfId",
to = "Column::Id",
on_update = "Cascade",
on_delete = "SetNull"
)]
SelfRef,
}
impl Related<super::location_block::Entity> for Entity {
fn to() -> RelationDef {
Relation::LocationBlock.def()
}
}
impl Related<super::proxy_config::Entity> for Entity {
fn to() -> RelationDef {
Relation::ProxyConfig.def()
}
}
impl ActiveModelBehavior for ActiveModel {}