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:
61
apps/nxmesh-master/src/db/entities/access_rule.rs
Normal file
61
apps/nxmesh-master/src/db/entities/access_rule.rs
Normal 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 {}
|
||||||
64
apps/nxmesh-master/src/db/entities/agent_config_binding.rs
Normal file
64
apps/nxmesh-master/src/db/entities/agent_config_binding.rs
Normal 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 {}
|
||||||
35
apps/nxmesh-master/src/db/entities/agent_group.rs
Normal file
35
apps/nxmesh-master/src/db/entities/agent_group.rs
Normal 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 {}
|
||||||
@@ -19,9 +19,33 @@ pub struct Model {
|
|||||||
pub labels: Option<Json>,
|
pub labels: Option<Json>,
|
||||||
pub created_at: DateTimeWithTimeZone,
|
pub created_at: DateTimeWithTimeZone,
|
||||||
pub updated_at: DateTimeWithTimeZone,
|
pub updated_at: DateTimeWithTimeZone,
|
||||||
|
pub group_id: Option<Uuid>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
#[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 {}
|
impl ActiveModelBehavior for ActiveModel {}
|
||||||
|
|||||||
37
apps/nxmesh-master/src/db/entities/cache_zone.rs
Normal file
37
apps/nxmesh-master/src/db/entities/cache_zone.rs
Normal 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 {}
|
||||||
37
apps/nxmesh-master/src/db/entities/config_inheritance.rs
Normal file
37
apps/nxmesh-master/src/db/entities/config_inheritance.rs
Normal 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 {}
|
||||||
59
apps/nxmesh-master/src/db/entities/limit_rule.rs
Normal file
59
apps/nxmesh-master/src/db/entities/limit_rule.rs
Normal 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 {}
|
||||||
37
apps/nxmesh-master/src/db/entities/limit_zone.rs
Normal file
37
apps/nxmesh-master/src/db/entities/limit_zone.rs
Normal 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 {}
|
||||||
91
apps/nxmesh-master/src/db/entities/location_block.rs
Normal file
91
apps/nxmesh-master/src/db/entities/location_block.rs
Normal 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 {}
|
||||||
44
apps/nxmesh-master/src/db/entities/log_setting.rs
Normal file
44
apps/nxmesh-master/src/db/entities/log_setting.rs
Normal 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 {}
|
||||||
@@ -2,5 +2,20 @@
|
|||||||
|
|
||||||
pub mod prelude;
|
pub mod prelude;
|
||||||
|
|
||||||
|
pub mod access_rule;
|
||||||
|
pub mod agent_config_binding;
|
||||||
|
pub mod agent_group;
|
||||||
pub mod agents;
|
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 public_key_revocations;
|
||||||
|
pub mod rewrite_rule;
|
||||||
|
pub mod server_block;
|
||||||
|
pub mod ssl_certificate;
|
||||||
|
pub mod upstream;
|
||||||
|
|||||||
@@ -1,4 +1,19 @@
|
|||||||
//! `SeaORM` Entity, @generated by sea-orm-codegen 2.0
|
//! `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::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::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;
|
||||||
|
|||||||
46
apps/nxmesh-master/src/db/entities/proxy_config.rs
Normal file
46
apps/nxmesh-master/src/db/entities/proxy_config.rs
Normal 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 {}
|
||||||
60
apps/nxmesh-master/src/db/entities/proxy_setting.rs
Normal file
60
apps/nxmesh-master/src/db/entities/proxy_setting.rs
Normal 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 {}
|
||||||
46
apps/nxmesh-master/src/db/entities/rewrite_rule.rs
Normal file
46
apps/nxmesh-master/src/db/entities/rewrite_rule.rs
Normal 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 {}
|
||||||
83
apps/nxmesh-master/src/db/entities/server_block.rs
Normal file
83
apps/nxmesh-master/src/db/entities/server_block.rs
Normal 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 {}
|
||||||
29
apps/nxmesh-master/src/db/entities/ssl_certificate.rs
Normal file
29
apps/nxmesh-master/src/db/entities/ssl_certificate.rs
Normal 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 {}
|
||||||
54
apps/nxmesh-master/src/db/entities/upstream.rs
Normal file
54
apps/nxmesh-master/src/db/entities/upstream.rs
Normal 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 {}
|
||||||
@@ -2,6 +2,7 @@ pub use sea_orm_migration::prelude::*;
|
|||||||
|
|
||||||
mod m20260301_000001_create_agents;
|
mod m20260301_000001_create_agents;
|
||||||
mod m20260301_000002_create_public_key_revokaction;
|
mod m20260301_000002_create_public_key_revokaction;
|
||||||
|
mod m20260620_111325_create_proxy_tables;
|
||||||
|
|
||||||
pub struct Migrator;
|
pub struct Migrator;
|
||||||
|
|
||||||
@@ -11,6 +12,7 @@ impl MigratorTrait for Migrator {
|
|||||||
vec![
|
vec![
|
||||||
Box::new(m20260301_000001_create_agents::Migration),
|
Box::new(m20260301_000001_create_agents::Migration),
|
||||||
Box::new(m20260301_000002_create_public_key_revokaction::Migration),
|
Box::new(m20260301_000002_create_public_key_revokaction::Migration),
|
||||||
|
Box::new(m20260620_111325_create_proxy_tables::Migration),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
902
crates/migration/src/m20260620_111325_create_proxy_tables.rs
Normal file
902
crates/migration/src/m20260620_111325_create_proxy_tables.rs
Normal file
@@ -0,0 +1,902 @@
|
|||||||
|
use sea_orm_migration::prelude::*;
|
||||||
|
|
||||||
|
#[derive(DeriveMigrationName)]
|
||||||
|
pub struct Migration;
|
||||||
|
|
||||||
|
#[async_trait::async_trait]
|
||||||
|
impl MigrationTrait for Migration {
|
||||||
|
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||||
|
manager
|
||||||
|
.create_table(
|
||||||
|
Table::create()
|
||||||
|
.table(AgentGroup::Table)
|
||||||
|
.if_not_exists()
|
||||||
|
.col(
|
||||||
|
ColumnDef::new(AgentGroup::Id)
|
||||||
|
.uuid()
|
||||||
|
.not_null()
|
||||||
|
.primary_key(),
|
||||||
|
)
|
||||||
|
.col(ColumnDef::new(AgentGroup::Name).string().not_null())
|
||||||
|
.col(ColumnDef::new(AgentGroup::Description).string())
|
||||||
|
.to_owned(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
manager
|
||||||
|
.alter_table(
|
||||||
|
Table::alter()
|
||||||
|
.table(Agents::Table)
|
||||||
|
.add_column(ColumnDef::new(Agents::GroupId).uuid().null())
|
||||||
|
.add_foreign_key(
|
||||||
|
TableForeignKey::new()
|
||||||
|
.name("fk_agents_group_id")
|
||||||
|
.from_tbl(Agents::Table)
|
||||||
|
.to_tbl(AgentGroup::Table)
|
||||||
|
.from_col(Agents::GroupId)
|
||||||
|
.to_col(AgentGroup::Id)
|
||||||
|
.on_delete(ForeignKeyAction::SetNull)
|
||||||
|
.on_update(ForeignKeyAction::Cascade),
|
||||||
|
)
|
||||||
|
.to_owned(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
manager
|
||||||
|
.create_table(
|
||||||
|
Table::create()
|
||||||
|
.table(ProxyConfig::Table)
|
||||||
|
.if_not_exists()
|
||||||
|
.col(
|
||||||
|
ColumnDef::new(ProxyConfig::Id)
|
||||||
|
.uuid()
|
||||||
|
.not_null()
|
||||||
|
.primary_key(),
|
||||||
|
)
|
||||||
|
.col(ColumnDef::new(ProxyConfig::Name).string().not_null())
|
||||||
|
.col(ColumnDef::new(ProxyConfig::Description).string())
|
||||||
|
.col(ColumnDef::new(ProxyConfig::IsTemplate).boolean().not_null())
|
||||||
|
.col(
|
||||||
|
ColumnDef::new(ProxyConfig::CreatedAt)
|
||||||
|
.timestamp()
|
||||||
|
.not_null(),
|
||||||
|
)
|
||||||
|
.col(
|
||||||
|
ColumnDef::new(ProxyConfig::UpdatedAt)
|
||||||
|
.timestamp()
|
||||||
|
.not_null(),
|
||||||
|
)
|
||||||
|
.to_owned(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
manager
|
||||||
|
.create_table(
|
||||||
|
Table::create()
|
||||||
|
.table(SSLCertificate::Table)
|
||||||
|
.if_not_exists()
|
||||||
|
.col(
|
||||||
|
ColumnDef::new(SSLCertificate::Id)
|
||||||
|
.uuid()
|
||||||
|
.not_null()
|
||||||
|
.primary_key(),
|
||||||
|
)
|
||||||
|
.col(ColumnDef::new(SSLCertificate::Name).string().not_null())
|
||||||
|
.col(ColumnDef::new(SSLCertificate::CertPath).string().not_null())
|
||||||
|
.col(ColumnDef::new(SSLCertificate::KeyPath).string().not_null())
|
||||||
|
.col(
|
||||||
|
ColumnDef::new(SSLCertificate::ExpiryDate)
|
||||||
|
.timestamp()
|
||||||
|
.not_null(),
|
||||||
|
)
|
||||||
|
.to_owned(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
manager
|
||||||
|
.create_table(
|
||||||
|
Table::create()
|
||||||
|
.table(CacheZone::Table)
|
||||||
|
.if_not_exists()
|
||||||
|
.col(
|
||||||
|
ColumnDef::new(CacheZone::Id)
|
||||||
|
.uuid()
|
||||||
|
.not_null()
|
||||||
|
.primary_key(),
|
||||||
|
)
|
||||||
|
.col(ColumnDef::new(CacheZone::Name).string().not_null())
|
||||||
|
.col(ColumnDef::new(CacheZone::Path).string().not_null())
|
||||||
|
.col(ColumnDef::new(CacheZone::SizeLimit).string().not_null())
|
||||||
|
.col(ColumnDef::new(CacheZone::OverrideOfId).uuid())
|
||||||
|
.foreign_key(
|
||||||
|
ForeignKey::create()
|
||||||
|
.name("fk_cache_zone_override_of")
|
||||||
|
.from_tbl(CacheZone::Table)
|
||||||
|
.to_tbl(CacheZone::Table)
|
||||||
|
.from_col(CacheZone::OverrideOfId)
|
||||||
|
.to_col(CacheZone::Id)
|
||||||
|
.on_delete(ForeignKeyAction::SetNull)
|
||||||
|
.on_update(ForeignKeyAction::Cascade),
|
||||||
|
)
|
||||||
|
.to_owned(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
manager
|
||||||
|
.create_table(
|
||||||
|
Table::create()
|
||||||
|
.table(LimitZone::Table)
|
||||||
|
.if_not_exists()
|
||||||
|
.col(
|
||||||
|
ColumnDef::new(LimitZone::Id)
|
||||||
|
.uuid()
|
||||||
|
.not_null()
|
||||||
|
.primary_key(),
|
||||||
|
)
|
||||||
|
.col(ColumnDef::new(LimitZone::Name).string().not_null())
|
||||||
|
.col(ColumnDef::new(LimitZone::Key).string().not_null())
|
||||||
|
.col(ColumnDef::new(LimitZone::Rate).string().not_null())
|
||||||
|
.col(ColumnDef::new(LimitZone::OverrideOfId).uuid())
|
||||||
|
.foreign_key(
|
||||||
|
ForeignKey::create()
|
||||||
|
.name("fk_limit_zone_override_of")
|
||||||
|
.from_tbl(LimitZone::Table)
|
||||||
|
.to_tbl(LimitZone::Table)
|
||||||
|
.from_col(LimitZone::OverrideOfId)
|
||||||
|
.to_col(LimitZone::Id)
|
||||||
|
.on_delete(ForeignKeyAction::SetNull)
|
||||||
|
.on_update(ForeignKeyAction::Cascade),
|
||||||
|
)
|
||||||
|
.to_owned(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
manager
|
||||||
|
.create_table(
|
||||||
|
Table::create()
|
||||||
|
.table(AgentConfigBinding::Table)
|
||||||
|
.if_not_exists()
|
||||||
|
.col(
|
||||||
|
ColumnDef::new(AgentConfigBinding::Id)
|
||||||
|
.uuid()
|
||||||
|
.not_null()
|
||||||
|
.primary_key(),
|
||||||
|
)
|
||||||
|
.col(ColumnDef::new(AgentConfigBinding::AgentId).uuid())
|
||||||
|
.col(ColumnDef::new(AgentConfigBinding::GroupId).uuid())
|
||||||
|
.col(
|
||||||
|
ColumnDef::new(AgentConfigBinding::ConfigId)
|
||||||
|
.uuid()
|
||||||
|
.not_null(),
|
||||||
|
)
|
||||||
|
.col(
|
||||||
|
ColumnDef::new(AgentConfigBinding::IsActive)
|
||||||
|
.boolean()
|
||||||
|
.not_null(),
|
||||||
|
)
|
||||||
|
.col(
|
||||||
|
ColumnDef::new(AgentConfigBinding::AppliedAt)
|
||||||
|
.timestamp()
|
||||||
|
.not_null(),
|
||||||
|
)
|
||||||
|
.foreign_key(
|
||||||
|
ForeignKey::create()
|
||||||
|
.name("fk_agent_config_binding_agent")
|
||||||
|
.from_tbl(AgentConfigBinding::Table)
|
||||||
|
.to_tbl(Agents::Table)
|
||||||
|
.from_col(AgentConfigBinding::AgentId)
|
||||||
|
.to_col(Agents::Id)
|
||||||
|
.on_delete(ForeignKeyAction::Cascade)
|
||||||
|
.on_update(ForeignKeyAction::Cascade),
|
||||||
|
)
|
||||||
|
.foreign_key(
|
||||||
|
ForeignKey::create()
|
||||||
|
.name("fk_agent_config_binding_group")
|
||||||
|
.from_tbl(AgentConfigBinding::Table)
|
||||||
|
.to_tbl(AgentGroup::Table)
|
||||||
|
.from_col(AgentConfigBinding::GroupId)
|
||||||
|
.to_col(AgentGroup::Id)
|
||||||
|
.on_delete(ForeignKeyAction::Cascade)
|
||||||
|
.on_update(ForeignKeyAction::Cascade),
|
||||||
|
)
|
||||||
|
.foreign_key(
|
||||||
|
ForeignKey::create()
|
||||||
|
.name("fk_agent_config_binding_config")
|
||||||
|
.from_tbl(AgentConfigBinding::Table)
|
||||||
|
.to_tbl(ProxyConfig::Table)
|
||||||
|
.from_col(AgentConfigBinding::ConfigId)
|
||||||
|
.to_col(ProxyConfig::Id)
|
||||||
|
.on_delete(ForeignKeyAction::Cascade)
|
||||||
|
.on_update(ForeignKeyAction::Cascade),
|
||||||
|
)
|
||||||
|
.to_owned(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
manager
|
||||||
|
.create_table(
|
||||||
|
Table::create()
|
||||||
|
.table(ConfigInheritance::Table)
|
||||||
|
.if_not_exists()
|
||||||
|
.col(
|
||||||
|
ColumnDef::new(ConfigInheritance::Id)
|
||||||
|
.uuid()
|
||||||
|
.not_null()
|
||||||
|
.primary_key(),
|
||||||
|
)
|
||||||
|
.col(
|
||||||
|
ColumnDef::new(ConfigInheritance::ChildConfigId)
|
||||||
|
.uuid()
|
||||||
|
.not_null(),
|
||||||
|
)
|
||||||
|
.col(
|
||||||
|
ColumnDef::new(ConfigInheritance::ParentConfigId)
|
||||||
|
.uuid()
|
||||||
|
.not_null(),
|
||||||
|
)
|
||||||
|
.col(ColumnDef::new(ConfigInheritance::Priority).integer())
|
||||||
|
.col(
|
||||||
|
ColumnDef::new(ConfigInheritance::AppliedAt)
|
||||||
|
.timestamp()
|
||||||
|
.not_null(),
|
||||||
|
)
|
||||||
|
.foreign_key(
|
||||||
|
ForeignKey::create()
|
||||||
|
.name("fk_config_inheritance_child")
|
||||||
|
.from_tbl(ConfigInheritance::Table)
|
||||||
|
.to_tbl(ProxyConfig::Table)
|
||||||
|
.from_col(ConfigInheritance::ChildConfigId)
|
||||||
|
.to_col(ProxyConfig::Id)
|
||||||
|
.on_delete(ForeignKeyAction::Cascade)
|
||||||
|
.on_update(ForeignKeyAction::Cascade),
|
||||||
|
)
|
||||||
|
.foreign_key(
|
||||||
|
ForeignKey::create()
|
||||||
|
.name("fk_config_inheritance_parent")
|
||||||
|
.from_tbl(ConfigInheritance::Table)
|
||||||
|
.to_tbl(ProxyConfig::Table)
|
||||||
|
.from_col(ConfigInheritance::ParentConfigId)
|
||||||
|
.to_col(ProxyConfig::Id)
|
||||||
|
.on_delete(ForeignKeyAction::Cascade)
|
||||||
|
.on_update(ForeignKeyAction::Cascade),
|
||||||
|
)
|
||||||
|
.to_owned(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
manager
|
||||||
|
.create_table(
|
||||||
|
Table::create()
|
||||||
|
.table(Upstream::Table)
|
||||||
|
.if_not_exists()
|
||||||
|
.col(ColumnDef::new(Upstream::Id).uuid().not_null().primary_key())
|
||||||
|
.col(ColumnDef::new(Upstream::ConfigId).uuid().not_null())
|
||||||
|
.col(ColumnDef::new(Upstream::Name).string().not_null())
|
||||||
|
.col(ColumnDef::new(Upstream::TargetHost).string().not_null())
|
||||||
|
.col(ColumnDef::new(Upstream::TargetPort).integer().not_null())
|
||||||
|
.col(ColumnDef::new(Upstream::Metadata).json_binary())
|
||||||
|
.col(ColumnDef::new(Upstream::OverrideOfId).uuid())
|
||||||
|
.foreign_key(
|
||||||
|
ForeignKey::create()
|
||||||
|
.name("fk_upstream_config")
|
||||||
|
.from_tbl(Upstream::Table)
|
||||||
|
.to_tbl(ProxyConfig::Table)
|
||||||
|
.from_col(Upstream::ConfigId)
|
||||||
|
.to_col(ProxyConfig::Id)
|
||||||
|
.on_delete(ForeignKeyAction::Cascade)
|
||||||
|
.on_update(ForeignKeyAction::Cascade),
|
||||||
|
)
|
||||||
|
.foreign_key(
|
||||||
|
ForeignKey::create()
|
||||||
|
.name("fk_upstream_override_of")
|
||||||
|
.from_tbl(Upstream::Table)
|
||||||
|
.to_tbl(Upstream::Table)
|
||||||
|
.from_col(Upstream::OverrideOfId)
|
||||||
|
.to_col(Upstream::Id)
|
||||||
|
.on_delete(ForeignKeyAction::SetNull)
|
||||||
|
.on_update(ForeignKeyAction::Cascade),
|
||||||
|
)
|
||||||
|
.to_owned(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
manager
|
||||||
|
.create_table(
|
||||||
|
Table::create()
|
||||||
|
.table(ServerBlock::Table)
|
||||||
|
.if_not_exists()
|
||||||
|
.col(
|
||||||
|
ColumnDef::new(ServerBlock::Id)
|
||||||
|
.uuid()
|
||||||
|
.not_null()
|
||||||
|
.primary_key(),
|
||||||
|
)
|
||||||
|
.col(ColumnDef::new(ServerBlock::ConfigId).uuid().not_null())
|
||||||
|
.col(
|
||||||
|
ColumnDef::new(ServerBlock::ServerName)
|
||||||
|
.array(ColumnType::String(StringLen::None)),
|
||||||
|
)
|
||||||
|
.col(ColumnDef::new(ServerBlock::ListenPort).integer().not_null())
|
||||||
|
.col(ColumnDef::new(ServerBlock::SslEnabled).boolean())
|
||||||
|
.col(ColumnDef::new(ServerBlock::SslCertId).uuid())
|
||||||
|
.col(ColumnDef::new(ServerBlock::OverrideOfId).uuid())
|
||||||
|
.foreign_key(
|
||||||
|
ForeignKey::create()
|
||||||
|
.name("fk_server_block_config")
|
||||||
|
.from_tbl(ServerBlock::Table)
|
||||||
|
.to_tbl(ProxyConfig::Table)
|
||||||
|
.from_col(ServerBlock::ConfigId)
|
||||||
|
.to_col(ProxyConfig::Id)
|
||||||
|
.on_delete(ForeignKeyAction::Cascade)
|
||||||
|
.on_update(ForeignKeyAction::Cascade),
|
||||||
|
)
|
||||||
|
.foreign_key(
|
||||||
|
ForeignKey::create()
|
||||||
|
.name("fk_server_block_ssl_cert")
|
||||||
|
.from_tbl(ServerBlock::Table)
|
||||||
|
.to_tbl(SSLCertificate::Table)
|
||||||
|
.from_col(ServerBlock::SslCertId)
|
||||||
|
.to_col(SSLCertificate::Id)
|
||||||
|
.on_delete(ForeignKeyAction::SetNull)
|
||||||
|
.on_update(ForeignKeyAction::Cascade),
|
||||||
|
)
|
||||||
|
.foreign_key(
|
||||||
|
ForeignKey::create()
|
||||||
|
.name("fk_server_block_override_of")
|
||||||
|
.from_tbl(ServerBlock::Table)
|
||||||
|
.to_tbl(ServerBlock::Table)
|
||||||
|
.from_col(ServerBlock::OverrideOfId)
|
||||||
|
.to_col(ServerBlock::Id)
|
||||||
|
.on_delete(ForeignKeyAction::SetNull)
|
||||||
|
.on_update(ForeignKeyAction::Cascade),
|
||||||
|
)
|
||||||
|
.to_owned(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
manager
|
||||||
|
.create_table(
|
||||||
|
Table::create()
|
||||||
|
.table(LocationBlock::Table)
|
||||||
|
.if_not_exists()
|
||||||
|
.col(
|
||||||
|
ColumnDef::new(LocationBlock::Id)
|
||||||
|
.uuid()
|
||||||
|
.not_null()
|
||||||
|
.primary_key(),
|
||||||
|
)
|
||||||
|
.col(ColumnDef::new(LocationBlock::ServerId).uuid().not_null())
|
||||||
|
.col(
|
||||||
|
ColumnDef::new(LocationBlock::PathPattern)
|
||||||
|
.string()
|
||||||
|
.not_null(),
|
||||||
|
)
|
||||||
|
.col(ColumnDef::new(LocationBlock::ProxyPassUpstreamId).uuid())
|
||||||
|
.col(ColumnDef::new(LocationBlock::Metadata).json_binary())
|
||||||
|
.col(ColumnDef::new(LocationBlock::OverrideOfId).uuid())
|
||||||
|
.foreign_key(
|
||||||
|
ForeignKey::create()
|
||||||
|
.name("fk_location_block_server")
|
||||||
|
.from_tbl(LocationBlock::Table)
|
||||||
|
.to_tbl(ServerBlock::Table)
|
||||||
|
.from_col(LocationBlock::ServerId)
|
||||||
|
.to_col(ServerBlock::Id)
|
||||||
|
.on_delete(ForeignKeyAction::Cascade)
|
||||||
|
.on_update(ForeignKeyAction::Cascade),
|
||||||
|
)
|
||||||
|
.foreign_key(
|
||||||
|
ForeignKey::create()
|
||||||
|
.name("fk_location_block_upstream")
|
||||||
|
.from_tbl(LocationBlock::Table)
|
||||||
|
.to_tbl(Upstream::Table)
|
||||||
|
.from_col(LocationBlock::ProxyPassUpstreamId)
|
||||||
|
.to_col(Upstream::Id)
|
||||||
|
.on_delete(ForeignKeyAction::SetNull)
|
||||||
|
.on_update(ForeignKeyAction::Cascade),
|
||||||
|
)
|
||||||
|
.foreign_key(
|
||||||
|
ForeignKey::create()
|
||||||
|
.name("fk_location_block_override_of")
|
||||||
|
.from_tbl(LocationBlock::Table)
|
||||||
|
.to_tbl(LocationBlock::Table)
|
||||||
|
.from_col(LocationBlock::OverrideOfId)
|
||||||
|
.to_col(LocationBlock::Id)
|
||||||
|
.on_delete(ForeignKeyAction::SetNull)
|
||||||
|
.on_update(ForeignKeyAction::Cascade),
|
||||||
|
)
|
||||||
|
.to_owned(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
manager
|
||||||
|
.create_table(
|
||||||
|
Table::create()
|
||||||
|
.table(AccessRule::Table)
|
||||||
|
.if_not_exists()
|
||||||
|
.col(
|
||||||
|
ColumnDef::new(AccessRule::Id)
|
||||||
|
.uuid()
|
||||||
|
.not_null()
|
||||||
|
.primary_key(),
|
||||||
|
)
|
||||||
|
.col(ColumnDef::new(AccessRule::ServerId).uuid())
|
||||||
|
.col(ColumnDef::new(AccessRule::LocationId).uuid())
|
||||||
|
.col(
|
||||||
|
ColumnDef::new(AccessRule::Type)
|
||||||
|
.string()
|
||||||
|
.not_null()
|
||||||
|
.comment("allow or deny"),
|
||||||
|
)
|
||||||
|
.col(
|
||||||
|
ColumnDef::new(AccessRule::IpCidr)
|
||||||
|
.string()
|
||||||
|
.not_null()
|
||||||
|
.comment("IP address or CIDR range. 0.0.0.0/0 means all IPs"),
|
||||||
|
)
|
||||||
|
.col(ColumnDef::new(AccessRule::Description).string())
|
||||||
|
.col(
|
||||||
|
ColumnDef::new(AccessRule::Priority)
|
||||||
|
.integer()
|
||||||
|
.not_null()
|
||||||
|
.comment(
|
||||||
|
"Priority of the access rule. Lower number means higher priority.",
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.col(ColumnDef::new(AccessRule::IsDeleted).boolean().not_null())
|
||||||
|
.col(ColumnDef::new(AccessRule::OverrideOfId).uuid())
|
||||||
|
.foreign_key(
|
||||||
|
ForeignKey::create()
|
||||||
|
.name("fk_access_rule_server")
|
||||||
|
.from_tbl(AccessRule::Table)
|
||||||
|
.to_tbl(ServerBlock::Table)
|
||||||
|
.from_col(AccessRule::ServerId)
|
||||||
|
.to_col(ServerBlock::Id)
|
||||||
|
.on_delete(ForeignKeyAction::Cascade)
|
||||||
|
.on_update(ForeignKeyAction::Cascade),
|
||||||
|
)
|
||||||
|
.foreign_key(
|
||||||
|
ForeignKey::create()
|
||||||
|
.name("fk_access_rule_location")
|
||||||
|
.from_tbl(AccessRule::Table)
|
||||||
|
.to_tbl(LocationBlock::Table)
|
||||||
|
.from_col(AccessRule::LocationId)
|
||||||
|
.to_col(LocationBlock::Id)
|
||||||
|
.on_delete(ForeignKeyAction::Cascade)
|
||||||
|
.on_update(ForeignKeyAction::Cascade),
|
||||||
|
)
|
||||||
|
.foreign_key(
|
||||||
|
ForeignKey::create()
|
||||||
|
.name("fk_access_rule_override_of")
|
||||||
|
.from_tbl(AccessRule::Table)
|
||||||
|
.to_tbl(AccessRule::Table)
|
||||||
|
.from_col(AccessRule::OverrideOfId)
|
||||||
|
.to_col(AccessRule::Id)
|
||||||
|
.on_delete(ForeignKeyAction::SetNull)
|
||||||
|
.on_update(ForeignKeyAction::Cascade),
|
||||||
|
)
|
||||||
|
.to_owned(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
manager
|
||||||
|
.create_table(
|
||||||
|
Table::create()
|
||||||
|
.table(RewriteRule::Table)
|
||||||
|
.if_not_exists()
|
||||||
|
.col(
|
||||||
|
ColumnDef::new(RewriteRule::Id)
|
||||||
|
.uuid()
|
||||||
|
.not_null()
|
||||||
|
.primary_key(),
|
||||||
|
)
|
||||||
|
.col(ColumnDef::new(RewriteRule::LocationId).uuid().not_null())
|
||||||
|
.col(ColumnDef::new(RewriteRule::Pattern).string().not_null())
|
||||||
|
.col(ColumnDef::new(RewriteRule::Replacement).string().not_null())
|
||||||
|
.col(ColumnDef::new(RewriteRule::Flag).string())
|
||||||
|
.col(ColumnDef::new(RewriteRule::Priority).integer().not_null())
|
||||||
|
.col(ColumnDef::new(RewriteRule::IsDeleted).boolean().not_null())
|
||||||
|
.col(ColumnDef::new(RewriteRule::OverrideOfId).uuid())
|
||||||
|
.foreign_key(
|
||||||
|
ForeignKey::create()
|
||||||
|
.name("fk_rewrite_rule_location")
|
||||||
|
.from_tbl(RewriteRule::Table)
|
||||||
|
.to_tbl(LocationBlock::Table)
|
||||||
|
.from_col(RewriteRule::LocationId)
|
||||||
|
.to_col(LocationBlock::Id)
|
||||||
|
.on_delete(ForeignKeyAction::Cascade),
|
||||||
|
)
|
||||||
|
.foreign_key(
|
||||||
|
ForeignKey::create()
|
||||||
|
.name("fk_rewrite_rule_override_of")
|
||||||
|
.from_tbl(RewriteRule::Table)
|
||||||
|
.to_tbl(RewriteRule::Table)
|
||||||
|
.from_col(RewriteRule::OverrideOfId)
|
||||||
|
.to_col(RewriteRule::Id)
|
||||||
|
.on_delete(ForeignKeyAction::SetNull)
|
||||||
|
.on_update(ForeignKeyAction::Cascade),
|
||||||
|
)
|
||||||
|
.to_owned(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
manager
|
||||||
|
.create_table(
|
||||||
|
Table::create()
|
||||||
|
.table(ProxySetting::Table)
|
||||||
|
.if_not_exists()
|
||||||
|
.col(
|
||||||
|
ColumnDef::new(ProxySetting::Id)
|
||||||
|
.uuid()
|
||||||
|
.not_null()
|
||||||
|
.primary_key(),
|
||||||
|
)
|
||||||
|
.col(ColumnDef::new(ProxySetting::LocationId).uuid().not_null())
|
||||||
|
.col(ColumnDef::new(ProxySetting::ReadTimeout).integer())
|
||||||
|
.col(ColumnDef::new(ProxySetting::ConnectTimeout).integer())
|
||||||
|
.col(ColumnDef::new(ProxySetting::BufferSize).integer())
|
||||||
|
.col(ColumnDef::new(ProxySetting::CacheEnabled).boolean())
|
||||||
|
.col(ColumnDef::new(ProxySetting::CacheZone).uuid())
|
||||||
|
.col(ColumnDef::new(ProxySetting::OverrideOfId).uuid())
|
||||||
|
.foreign_key(
|
||||||
|
ForeignKey::create()
|
||||||
|
.name("fk_proxy_setting_location")
|
||||||
|
.from_tbl(ProxySetting::Table)
|
||||||
|
.to_tbl(LocationBlock::Table)
|
||||||
|
.from_col(ProxySetting::LocationId)
|
||||||
|
.to_col(LocationBlock::Id)
|
||||||
|
.on_delete(ForeignKeyAction::Cascade),
|
||||||
|
)
|
||||||
|
.foreign_key(
|
||||||
|
ForeignKey::create()
|
||||||
|
.name("fk_proxy_setting_cache_zone")
|
||||||
|
.from_tbl(ProxySetting::Table)
|
||||||
|
.to_tbl(CacheZone::Table)
|
||||||
|
.from_col(ProxySetting::CacheZone)
|
||||||
|
.to_col(CacheZone::Id)
|
||||||
|
.on_delete(ForeignKeyAction::SetNull),
|
||||||
|
)
|
||||||
|
.foreign_key(
|
||||||
|
ForeignKey::create()
|
||||||
|
.name("fk_proxy_setting_override_of")
|
||||||
|
.from_tbl(ProxySetting::Table)
|
||||||
|
.to_tbl(ProxySetting::Table)
|
||||||
|
.from_col(ProxySetting::OverrideOfId)
|
||||||
|
.to_col(ProxySetting::Id)
|
||||||
|
.on_delete(ForeignKeyAction::SetNull)
|
||||||
|
.on_update(ForeignKeyAction::Cascade),
|
||||||
|
)
|
||||||
|
.to_owned(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
manager
|
||||||
|
.create_table(
|
||||||
|
Table::create()
|
||||||
|
.table(LimitRule::Table)
|
||||||
|
.if_not_exists()
|
||||||
|
.col(
|
||||||
|
ColumnDef::new(LimitRule::Id)
|
||||||
|
.uuid()
|
||||||
|
.not_null()
|
||||||
|
.primary_key(),
|
||||||
|
)
|
||||||
|
.col(ColumnDef::new(LimitRule::LocationId).uuid().not_null())
|
||||||
|
.col(ColumnDef::new(LimitRule::ZoneId).uuid().not_null())
|
||||||
|
.col(ColumnDef::new(LimitRule::Burst).integer())
|
||||||
|
.col(ColumnDef::new(LimitRule::Nodelay).boolean())
|
||||||
|
.col(ColumnDef::new(LimitRule::IsDeleted).boolean().not_null())
|
||||||
|
.col(ColumnDef::new(LimitRule::OverrideOfId).uuid())
|
||||||
|
.foreign_key(
|
||||||
|
ForeignKey::create()
|
||||||
|
.name("fk_limit_rule_location")
|
||||||
|
.from_tbl(LimitRule::Table)
|
||||||
|
.to_tbl(LocationBlock::Table)
|
||||||
|
.from_col(LimitRule::LocationId)
|
||||||
|
.to_col(LocationBlock::Id)
|
||||||
|
.on_delete(ForeignKeyAction::Cascade),
|
||||||
|
)
|
||||||
|
.foreign_key(
|
||||||
|
ForeignKey::create()
|
||||||
|
.name("fk_limit_rule_zone")
|
||||||
|
.from_tbl(LimitRule::Table)
|
||||||
|
.to_tbl(LimitZone::Table)
|
||||||
|
.from_col(LimitRule::ZoneId)
|
||||||
|
.to_col(LimitZone::Id)
|
||||||
|
.on_delete(ForeignKeyAction::Cascade),
|
||||||
|
)
|
||||||
|
.foreign_key(
|
||||||
|
ForeignKey::create()
|
||||||
|
.name("fk_limit_rule_override_of")
|
||||||
|
.from_tbl(LimitRule::Table)
|
||||||
|
.to_tbl(LimitRule::Table)
|
||||||
|
.from_col(LimitRule::OverrideOfId)
|
||||||
|
.to_col(LimitRule::Id)
|
||||||
|
.on_delete(ForeignKeyAction::SetNull)
|
||||||
|
.on_update(ForeignKeyAction::Cascade),
|
||||||
|
)
|
||||||
|
.to_owned(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
manager
|
||||||
|
.create_table(
|
||||||
|
Table::create()
|
||||||
|
.table(LogSetting::Table)
|
||||||
|
.if_not_exists()
|
||||||
|
.col(
|
||||||
|
ColumnDef::new(LogSetting::Id)
|
||||||
|
.uuid()
|
||||||
|
.not_null()
|
||||||
|
.primary_key(),
|
||||||
|
)
|
||||||
|
.col(ColumnDef::new(LogSetting::ServerId).uuid().not_null())
|
||||||
|
.col(ColumnDef::new(LogSetting::AccessLogPath).string())
|
||||||
|
.col(ColumnDef::new(LogSetting::ErrorLogPath).string())
|
||||||
|
.col(ColumnDef::new(LogSetting::LogLevel).string())
|
||||||
|
.col(ColumnDef::new(LogSetting::OverrideOfId).uuid())
|
||||||
|
.foreign_key(
|
||||||
|
ForeignKey::create()
|
||||||
|
.name("fk_log_setting_server")
|
||||||
|
.from_tbl(LogSetting::Table)
|
||||||
|
.to_tbl(ServerBlock::Table)
|
||||||
|
.from_col(LogSetting::ServerId)
|
||||||
|
.to_col(ServerBlock::Id)
|
||||||
|
.on_delete(ForeignKeyAction::Cascade),
|
||||||
|
)
|
||||||
|
.foreign_key(
|
||||||
|
ForeignKey::create()
|
||||||
|
.name("fk_log_setting_override_of")
|
||||||
|
.from_tbl(LogSetting::Table)
|
||||||
|
.to_tbl(LogSetting::Table)
|
||||||
|
.from_col(LogSetting::OverrideOfId)
|
||||||
|
.to_col(LogSetting::Id)
|
||||||
|
.on_delete(ForeignKeyAction::SetNull)
|
||||||
|
.on_update(ForeignKeyAction::Cascade),
|
||||||
|
)
|
||||||
|
.to_owned(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||||
|
manager
|
||||||
|
.drop_table(Table::drop().table(LogSetting::Table).to_owned())
|
||||||
|
.await?;
|
||||||
|
manager
|
||||||
|
.drop_table(Table::drop().table(LimitRule::Table).to_owned())
|
||||||
|
.await?;
|
||||||
|
manager
|
||||||
|
.drop_table(Table::drop().table(ProxySetting::Table).to_owned())
|
||||||
|
.await?;
|
||||||
|
manager
|
||||||
|
.drop_table(Table::drop().table(RewriteRule::Table).to_owned())
|
||||||
|
.await?;
|
||||||
|
manager
|
||||||
|
.drop_table(Table::drop().table(AccessRule::Table).to_owned())
|
||||||
|
.await?;
|
||||||
|
manager
|
||||||
|
.drop_table(Table::drop().table(LocationBlock::Table).to_owned())
|
||||||
|
.await?;
|
||||||
|
manager
|
||||||
|
.drop_table(Table::drop().table(ServerBlock::Table).to_owned())
|
||||||
|
.await?;
|
||||||
|
manager
|
||||||
|
.drop_table(Table::drop().table(Upstream::Table).to_owned())
|
||||||
|
.await?;
|
||||||
|
manager
|
||||||
|
.drop_table(Table::drop().table(ConfigInheritance::Table).to_owned())
|
||||||
|
.await?;
|
||||||
|
manager
|
||||||
|
.drop_table(Table::drop().table(AgentConfigBinding::Table).to_owned())
|
||||||
|
.await?;
|
||||||
|
manager
|
||||||
|
.drop_table(Table::drop().table(LimitZone::Table).to_owned())
|
||||||
|
.await?;
|
||||||
|
manager
|
||||||
|
.drop_table(Table::drop().table(CacheZone::Table).to_owned())
|
||||||
|
.await?;
|
||||||
|
manager
|
||||||
|
.drop_table(Table::drop().table(SSLCertificate::Table).to_owned())
|
||||||
|
.await?;
|
||||||
|
manager
|
||||||
|
.drop_table(Table::drop().table(ProxyConfig::Table).to_owned())
|
||||||
|
.await?;
|
||||||
|
manager
|
||||||
|
.alter_table(
|
||||||
|
Table::alter()
|
||||||
|
.table(Agents::Table)
|
||||||
|
.drop_foreign_key(Alias::new("fk_agents_group_id"))
|
||||||
|
.to_owned(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
manager
|
||||||
|
.alter_table(
|
||||||
|
Table::alter()
|
||||||
|
.table(Agents::Table)
|
||||||
|
.drop_column(Agents::GroupId)
|
||||||
|
.to_owned(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
manager
|
||||||
|
.drop_table(Table::drop().table(AgentGroup::Table).to_owned())
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(DeriveIden)]
|
||||||
|
enum Agents {
|
||||||
|
Table,
|
||||||
|
Id,
|
||||||
|
GroupId,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(DeriveIden)]
|
||||||
|
enum AgentGroup {
|
||||||
|
Table,
|
||||||
|
Id,
|
||||||
|
Name,
|
||||||
|
Description,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(DeriveIden)]
|
||||||
|
enum AgentConfigBinding {
|
||||||
|
Table,
|
||||||
|
Id,
|
||||||
|
AgentId,
|
||||||
|
GroupId,
|
||||||
|
ConfigId,
|
||||||
|
IsActive,
|
||||||
|
AppliedAt,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(DeriveIden)]
|
||||||
|
enum ProxyConfig {
|
||||||
|
Table,
|
||||||
|
Id,
|
||||||
|
Name,
|
||||||
|
Description,
|
||||||
|
IsTemplate,
|
||||||
|
CreatedAt,
|
||||||
|
UpdatedAt,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(DeriveIden)]
|
||||||
|
enum ConfigInheritance {
|
||||||
|
Table,
|
||||||
|
Id,
|
||||||
|
ChildConfigId,
|
||||||
|
ParentConfigId,
|
||||||
|
Priority,
|
||||||
|
AppliedAt,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(DeriveIden)]
|
||||||
|
enum SSLCertificate {
|
||||||
|
Table,
|
||||||
|
Id,
|
||||||
|
Name,
|
||||||
|
CertPath,
|
||||||
|
KeyPath,
|
||||||
|
ExpiryDate,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(DeriveIden)]
|
||||||
|
enum CacheZone {
|
||||||
|
Table,
|
||||||
|
Id,
|
||||||
|
Name,
|
||||||
|
Path,
|
||||||
|
SizeLimit,
|
||||||
|
OverrideOfId,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(DeriveIden)]
|
||||||
|
enum LimitZone {
|
||||||
|
Table,
|
||||||
|
Id,
|
||||||
|
Name,
|
||||||
|
Key,
|
||||||
|
Rate,
|
||||||
|
OverrideOfId,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(DeriveIden)]
|
||||||
|
enum Upstream {
|
||||||
|
Table,
|
||||||
|
Id,
|
||||||
|
ConfigId,
|
||||||
|
Name,
|
||||||
|
TargetHost,
|
||||||
|
TargetPort,
|
||||||
|
Metadata,
|
||||||
|
OverrideOfId,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(DeriveIden)]
|
||||||
|
enum ServerBlock {
|
||||||
|
Table,
|
||||||
|
Id,
|
||||||
|
ConfigId,
|
||||||
|
ServerName,
|
||||||
|
ListenPort,
|
||||||
|
SslEnabled,
|
||||||
|
SslCertId,
|
||||||
|
OverrideOfId,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(DeriveIden)]
|
||||||
|
enum LocationBlock {
|
||||||
|
Table,
|
||||||
|
Id,
|
||||||
|
ServerId,
|
||||||
|
PathPattern,
|
||||||
|
ProxyPassUpstreamId,
|
||||||
|
Metadata,
|
||||||
|
OverrideOfId,
|
||||||
|
}
|
||||||
|
#[derive(DeriveIden)]
|
||||||
|
enum AccessRule {
|
||||||
|
Table,
|
||||||
|
Id,
|
||||||
|
ServerId,
|
||||||
|
LocationId,
|
||||||
|
Type,
|
||||||
|
IpCidr,
|
||||||
|
Priority,
|
||||||
|
Description,
|
||||||
|
IsDeleted,
|
||||||
|
OverrideOfId,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(DeriveIden)]
|
||||||
|
enum RewriteRule {
|
||||||
|
Table,
|
||||||
|
Id,
|
||||||
|
LocationId,
|
||||||
|
Pattern,
|
||||||
|
Replacement,
|
||||||
|
Flag,
|
||||||
|
Priority,
|
||||||
|
IsDeleted,
|
||||||
|
OverrideOfId,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(DeriveIden)]
|
||||||
|
enum ProxySetting {
|
||||||
|
Table,
|
||||||
|
Id,
|
||||||
|
LocationId,
|
||||||
|
ReadTimeout,
|
||||||
|
ConnectTimeout,
|
||||||
|
BufferSize,
|
||||||
|
CacheEnabled,
|
||||||
|
CacheZone,
|
||||||
|
OverrideOfId,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(DeriveIden)]
|
||||||
|
enum LimitRule {
|
||||||
|
Table,
|
||||||
|
Id,
|
||||||
|
LocationId,
|
||||||
|
ZoneId,
|
||||||
|
Burst,
|
||||||
|
Nodelay,
|
||||||
|
IsDeleted,
|
||||||
|
OverrideOfId,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(DeriveIden)]
|
||||||
|
enum LogSetting {
|
||||||
|
Table,
|
||||||
|
Id,
|
||||||
|
ServerId,
|
||||||
|
AccessLogPath,
|
||||||
|
ErrorLogPath,
|
||||||
|
LogLevel,
|
||||||
|
OverrideOfId,
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user