feature/proxy-service #14
46
public/database/src/generated/entities/location.rs
Normal file
46
public/database/src/generated/entities/location.rs
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
//! `SeaORM` Entity, @generated by sea-orm-codegen 2.0.0-rc.18
|
||||||
|
|
||||||
|
use sea_orm::entity::prelude::*;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[sea_orm::model]
|
||||||
|
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Serialize, Deserialize)]
|
||||||
|
#[sea_orm(table_name = "location")]
|
||||||
|
pub struct Model {
|
||||||
|
#[sea_orm(primary_key, auto_increment = false)]
|
||||||
|
pub id: Uuid,
|
||||||
|
pub host_id: Uuid,
|
||||||
|
pub path: String,
|
||||||
|
pub match_type: String,
|
||||||
|
pub order: i64,
|
||||||
|
pub upstream_id: Option<Uuid>,
|
||||||
|
pub proxy_pass_protocol: Option<String>,
|
||||||
|
pub proxy_pass_host: Option<String>,
|
||||||
|
pub proxy_pass_port: Option<i64>,
|
||||||
|
pub preserve_host_header: Option<bool>,
|
||||||
|
#[sea_orm(column_type = "JsonBinary", nullable)]
|
||||||
|
pub allowed_methods: Option<Json>,
|
||||||
|
#[sea_orm(column_type = "Text", nullable)]
|
||||||
|
pub custom_config: Option<String>,
|
||||||
|
pub enabled: bool,
|
||||||
|
pub created_at: DateTimeUtc,
|
||||||
|
pub updated_at: DateTimeUtc,
|
||||||
|
#[sea_orm(
|
||||||
|
belongs_to,
|
||||||
|
from = "host_id",
|
||||||
|
to = "id",
|
||||||
|
on_update = "Cascade",
|
||||||
|
on_delete = "Cascade"
|
||||||
|
)]
|
||||||
|
pub proxy_host: HasOne<super::proxy_host::Entity>,
|
||||||
|
#[sea_orm(
|
||||||
|
belongs_to,
|
||||||
|
from = "upstream_id",
|
||||||
|
to = "id",
|
||||||
|
on_update = "Cascade",
|
||||||
|
on_delete = "SetNull"
|
||||||
|
)]
|
||||||
|
pub upstream: HasOne<super::upstream::Entity>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ActiveModelBehavior for ActiveModel {}
|
||||||
@@ -3,6 +3,8 @@
|
|||||||
pub mod prelude;
|
pub mod prelude;
|
||||||
|
|
||||||
pub mod config;
|
pub mod config;
|
||||||
|
pub mod location;
|
||||||
|
pub mod proxy_host;
|
||||||
pub mod upstream;
|
pub mod upstream;
|
||||||
pub mod upstream_target;
|
pub mod upstream_target;
|
||||||
pub mod user;
|
pub mod user;
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
//! `SeaORM` Entity, @generated by sea-orm-codegen 2.0.0-rc.18
|
//! `SeaORM` Entity, @generated by sea-orm-codegen 2.0.0-rc.18
|
||||||
|
|
||||||
pub use super::config::Entity as Config;
|
pub use super::config::Entity as Config;
|
||||||
|
pub use super::location::Entity as Location;
|
||||||
|
pub use super::proxy_host::Entity as ProxyHost;
|
||||||
pub use super::upstream::Entity as Upstream;
|
pub use super::upstream::Entity as Upstream;
|
||||||
pub use super::upstream_target::Entity as UpstreamTarget;
|
pub use super::upstream_target::Entity as UpstreamTarget;
|
||||||
pub use super::user::Entity as User;
|
pub use super::user::Entity as User;
|
||||||
|
|||||||
48
public/database/src/generated/entities/proxy_host.rs
Normal file
48
public/database/src/generated/entities/proxy_host.rs
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
//! `SeaORM` Entity, @generated by sea-orm-codegen 2.0.0-rc.18
|
||||||
|
|
||||||
|
use sea_orm::entity::prelude::*;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[sea_orm::model]
|
||||||
|
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Serialize, Deserialize)]
|
||||||
|
#[sea_orm(table_name = "proxy_host")]
|
||||||
|
pub struct Model {
|
||||||
|
#[sea_orm(primary_key, auto_increment = false)]
|
||||||
|
pub id: Uuid,
|
||||||
|
pub name: Option<String>,
|
||||||
|
pub domain: String,
|
||||||
|
pub scheme: String,
|
||||||
|
pub listen_port: i64,
|
||||||
|
pub forward_scheme: String,
|
||||||
|
pub forward_host: Option<String>,
|
||||||
|
pub forward_port: Option<i64>,
|
||||||
|
pub preserve_host_header: bool,
|
||||||
|
pub enable_websocket: bool,
|
||||||
|
pub enabled: bool,
|
||||||
|
#[sea_orm(column_type = "JsonBinary", nullable)]
|
||||||
|
pub meta: Option<Json>,
|
||||||
|
pub default_upstream_id: Option<Uuid>,
|
||||||
|
pub created_by: Option<Uuid>,
|
||||||
|
pub created_at: DateTimeUtc,
|
||||||
|
pub updated_at: DateTimeUtc,
|
||||||
|
#[sea_orm(has_many)]
|
||||||
|
pub locations: HasMany<super::location::Entity>,
|
||||||
|
#[sea_orm(
|
||||||
|
belongs_to,
|
||||||
|
from = "default_upstream_id",
|
||||||
|
to = "id",
|
||||||
|
on_update = "Cascade",
|
||||||
|
on_delete = "SetNull"
|
||||||
|
)]
|
||||||
|
pub upstream: HasOne<super::upstream::Entity>,
|
||||||
|
#[sea_orm(
|
||||||
|
belongs_to,
|
||||||
|
from = "created_by",
|
||||||
|
to = "id",
|
||||||
|
on_update = "Cascade",
|
||||||
|
on_delete = "SetNull"
|
||||||
|
)]
|
||||||
|
pub user: HasOne<super::user::Entity>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ActiveModelBehavior for ActiveModel {}
|
||||||
@@ -17,6 +17,10 @@ pub struct Model {
|
|||||||
pub created_at: DateTimeUtc,
|
pub created_at: DateTimeUtc,
|
||||||
pub updated_at: DateTimeUtc,
|
pub updated_at: DateTimeUtc,
|
||||||
#[sea_orm(has_many)]
|
#[sea_orm(has_many)]
|
||||||
|
pub locations: HasMany<super::location::Entity>,
|
||||||
|
#[sea_orm(has_many)]
|
||||||
|
pub proxy_hosts: HasMany<super::proxy_host::Entity>,
|
||||||
|
#[sea_orm(has_many)]
|
||||||
pub upstream_targets: HasMany<super::upstream_target::Entity>,
|
pub upstream_targets: HasMany<super::upstream_target::Entity>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ pub struct Model {
|
|||||||
pub last_login_at: Option<DateTimeUtc>,
|
pub last_login_at: Option<DateTimeUtc>,
|
||||||
pub deleted_at: Option<DateTimeUtc>,
|
pub deleted_at: Option<DateTimeUtc>,
|
||||||
#[sea_orm(has_many)]
|
#[sea_orm(has_many)]
|
||||||
|
pub proxy_hosts: HasMany<super::proxy_host::Entity>,
|
||||||
|
#[sea_orm(has_many)]
|
||||||
pub user_identities: HasMany<super::user_identity::Entity>,
|
pub user_identities: HasMany<super::user_identity::Entity>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ impl MigratorTrait for Migrator {
|
|||||||
Box::new(m20251011_000003_create_user_identity_table::Migration),
|
Box::new(m20251011_000003_create_user_identity_table::Migration),
|
||||||
Box::new(m20251223_000004_create_upstream_table::Migration),
|
Box::new(m20251223_000004_create_upstream_table::Migration),
|
||||||
Box::new(m20251223_000005_create_upstream_target_table::Migration),
|
Box::new(m20251223_000005_create_upstream_target_table::Migration),
|
||||||
|
Box::new(m20260102_000006_create_proxy_table::Migration),
|
||||||
|
Box::new(m20260102_000007_create_location_table::Migration),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,3 +3,5 @@ pub mod m20251011_000002_create_user_table;
|
|||||||
pub mod m20251011_000003_create_user_identity_table;
|
pub mod m20251011_000003_create_user_identity_table;
|
||||||
pub mod m20251223_000004_create_upstream_table;
|
pub mod m20251223_000004_create_upstream_table;
|
||||||
pub mod m20251223_000005_create_upstream_target_table;
|
pub mod m20251223_000005_create_upstream_target_table;
|
||||||
|
pub mod m20260102_000006_create_proxy_table;
|
||||||
|
pub mod m20260102_000007_create_location_table;
|
||||||
|
|||||||
@@ -0,0 +1,124 @@
|
|||||||
|
use sea_orm_migration::{prelude::*, schema::*};
|
||||||
|
|
||||||
|
#[derive(DeriveMigrationName)]
|
||||||
|
pub struct Migration;
|
||||||
|
|
||||||
|
#[forbid(dead_code)]
|
||||||
|
#[derive(DeriveIden)]
|
||||||
|
pub enum ProxyHost {
|
||||||
|
Table,
|
||||||
|
Id,
|
||||||
|
Name,
|
||||||
|
Domain,
|
||||||
|
Scheme,
|
||||||
|
ListenPort,
|
||||||
|
ForwardScheme,
|
||||||
|
ForwardHost,
|
||||||
|
ForwardPort,
|
||||||
|
PreserveHostHeader,
|
||||||
|
EnableWebsocket,
|
||||||
|
Enabled,
|
||||||
|
Meta,
|
||||||
|
DefaultUpstreamId,
|
||||||
|
CreatedBy,
|
||||||
|
CreatedAt,
|
||||||
|
UpdatedAt,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[async_trait::async_trait]
|
||||||
|
impl MigrationTrait for Migration {
|
||||||
|
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||||
|
manager
|
||||||
|
.create_table(
|
||||||
|
Table::create()
|
||||||
|
.table(ProxyHost::Table)
|
||||||
|
.if_not_exists()
|
||||||
|
.col(pk_uuid(ProxyHost::Id))
|
||||||
|
.col(ColumnDef::new(ProxyHost::Name).string().null())
|
||||||
|
.col(ColumnDef::new(ProxyHost::Domain).string().not_null())
|
||||||
|
.col(
|
||||||
|
ColumnDef::new(ProxyHost::Scheme)
|
||||||
|
.string()
|
||||||
|
.default("http")
|
||||||
|
.not_null(),
|
||||||
|
)
|
||||||
|
.col(
|
||||||
|
ColumnDef::new(ProxyHost::ListenPort)
|
||||||
|
.integer()
|
||||||
|
.default(80)
|
||||||
|
.not_null(),
|
||||||
|
)
|
||||||
|
.col(
|
||||||
|
ColumnDef::new(ProxyHost::ForwardScheme)
|
||||||
|
.string()
|
||||||
|
.default("http")
|
||||||
|
.not_null(),
|
||||||
|
)
|
||||||
|
.col(ColumnDef::new(ProxyHost::ForwardHost).string().null())
|
||||||
|
.col(ColumnDef::new(ProxyHost::ForwardPort).integer().null())
|
||||||
|
.col(
|
||||||
|
ColumnDef::new(ProxyHost::PreserveHostHeader)
|
||||||
|
.boolean()
|
||||||
|
.default(false)
|
||||||
|
.not_null(),
|
||||||
|
)
|
||||||
|
.col(
|
||||||
|
ColumnDef::new(ProxyHost::EnableWebsocket)
|
||||||
|
.boolean()
|
||||||
|
.default(false)
|
||||||
|
.not_null(),
|
||||||
|
)
|
||||||
|
.col(
|
||||||
|
ColumnDef::new(ProxyHost::Enabled)
|
||||||
|
.boolean()
|
||||||
|
.default(true)
|
||||||
|
.not_null(),
|
||||||
|
)
|
||||||
|
.col(ColumnDef::new(ProxyHost::Meta).json_binary().null())
|
||||||
|
.col(ColumnDef::new(ProxyHost::DefaultUpstreamId).uuid().null())
|
||||||
|
.foreign_key(
|
||||||
|
ForeignKey::create()
|
||||||
|
.name("fk-proxy-host-default-upstream-id")
|
||||||
|
.from(ProxyHost::Table, ProxyHost::DefaultUpstreamId)
|
||||||
|
.to(
|
||||||
|
super::m20251223_000004_create_upstream_table::Upstream::Table,
|
||||||
|
super::m20251223_000004_create_upstream_table::Upstream::Id,
|
||||||
|
)
|
||||||
|
.on_delete(ForeignKeyAction::SetNull)
|
||||||
|
.on_update(ForeignKeyAction::Cascade),
|
||||||
|
)
|
||||||
|
.col(ColumnDef::new(ProxyHost::CreatedBy).uuid().null())
|
||||||
|
.foreign_key(
|
||||||
|
ForeignKey::create()
|
||||||
|
.name("fk-proxy-host-created-by")
|
||||||
|
.from(ProxyHost::Table, ProxyHost::CreatedBy)
|
||||||
|
.to(
|
||||||
|
super::m20251011_000002_create_user_table::User::Table,
|
||||||
|
super::m20251011_000002_create_user_table::User::Id,
|
||||||
|
)
|
||||||
|
.on_delete(ForeignKeyAction::SetNull)
|
||||||
|
.on_update(ForeignKeyAction::Cascade),
|
||||||
|
)
|
||||||
|
.col(
|
||||||
|
ColumnDef::new(ProxyHost::CreatedAt)
|
||||||
|
.timestamp()
|
||||||
|
.default(SimpleExpr::Keyword(Keyword::CurrentTimestamp))
|
||||||
|
.not_null(),
|
||||||
|
)
|
||||||
|
.col(
|
||||||
|
ColumnDef::new(ProxyHost::UpdatedAt)
|
||||||
|
.timestamp()
|
||||||
|
.default(SimpleExpr::Keyword(Keyword::CurrentTimestamp))
|
||||||
|
.not_null(),
|
||||||
|
)
|
||||||
|
.to_owned(),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||||
|
manager
|
||||||
|
.drop_table(Table::drop().table(ProxyHost::Table).to_owned())
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,115 @@
|
|||||||
|
use sea_orm_migration::{prelude::*, schema::*};
|
||||||
|
|
||||||
|
#[derive(DeriveMigrationName)]
|
||||||
|
pub struct Migration;
|
||||||
|
|
||||||
|
#[forbid(dead_code)]
|
||||||
|
#[derive(DeriveIden)]
|
||||||
|
pub enum Location {
|
||||||
|
Table,
|
||||||
|
Id,
|
||||||
|
HostId,
|
||||||
|
Path,
|
||||||
|
MatchType,
|
||||||
|
Order,
|
||||||
|
UpstreamId,
|
||||||
|
ProxyPassProtocol,
|
||||||
|
ProxyPassHost,
|
||||||
|
ProxyPassPort,
|
||||||
|
PreserveHostHeader,
|
||||||
|
AllowedMethods,
|
||||||
|
CustomConfig,
|
||||||
|
Enabled,
|
||||||
|
CreatedAt,
|
||||||
|
UpdatedAt,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[async_trait::async_trait]
|
||||||
|
impl MigrationTrait for Migration {
|
||||||
|
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||||
|
manager
|
||||||
|
.create_table(
|
||||||
|
Table::create()
|
||||||
|
.table(Location::Table)
|
||||||
|
.if_not_exists()
|
||||||
|
.col(pk_uuid(Location::Id))
|
||||||
|
.col(ColumnDef::new(Location::HostId).uuid().not_null())
|
||||||
|
.foreign_key(
|
||||||
|
ForeignKey::create()
|
||||||
|
.name("fk-location-host-id")
|
||||||
|
.from(Location::Table, Location::HostId)
|
||||||
|
.to(
|
||||||
|
super::m20260102_000006_create_proxy_table::ProxyHost::Table,
|
||||||
|
super::m20260102_000006_create_proxy_table::ProxyHost::Id,
|
||||||
|
)
|
||||||
|
.on_delete(ForeignKeyAction::Cascade)
|
||||||
|
.on_update(ForeignKeyAction::Cascade),
|
||||||
|
)
|
||||||
|
.col(ColumnDef::new(Location::Path).string().not_null())
|
||||||
|
.col(
|
||||||
|
ColumnDef::new(Location::MatchType)
|
||||||
|
.string()
|
||||||
|
.default("prefix")
|
||||||
|
.not_null(),
|
||||||
|
)
|
||||||
|
.col(
|
||||||
|
ColumnDef::new(Location::Order)
|
||||||
|
.integer()
|
||||||
|
.default(0)
|
||||||
|
.not_null(),
|
||||||
|
)
|
||||||
|
.col(ColumnDef::new(Location::UpstreamId).uuid().null())
|
||||||
|
.foreign_key(
|
||||||
|
ForeignKey::create()
|
||||||
|
.name("fk-location-upstream-id")
|
||||||
|
.from(Location::Table, Location::UpstreamId)
|
||||||
|
.to(
|
||||||
|
super::m20251223_000004_create_upstream_table::Upstream::Table,
|
||||||
|
super::m20251223_000004_create_upstream_table::Upstream::Id,
|
||||||
|
)
|
||||||
|
.on_delete(ForeignKeyAction::SetNull)
|
||||||
|
.on_update(ForeignKeyAction::Cascade),
|
||||||
|
)
|
||||||
|
.col(ColumnDef::new(Location::ProxyPassProtocol).string().null())
|
||||||
|
.col(ColumnDef::new(Location::ProxyPassHost).string().null())
|
||||||
|
.col(ColumnDef::new(Location::ProxyPassPort).integer().null())
|
||||||
|
.col(
|
||||||
|
ColumnDef::new(Location::PreserveHostHeader)
|
||||||
|
.boolean()
|
||||||
|
.null(),
|
||||||
|
)
|
||||||
|
.col(
|
||||||
|
ColumnDef::new(Location::AllowedMethods)
|
||||||
|
.json_binary()
|
||||||
|
.null(),
|
||||||
|
)
|
||||||
|
.col(ColumnDef::new(Location::CustomConfig).text().null())
|
||||||
|
.col(
|
||||||
|
ColumnDef::new(Location::Enabled)
|
||||||
|
.boolean()
|
||||||
|
.default(true)
|
||||||
|
.not_null(),
|
||||||
|
)
|
||||||
|
.col(
|
||||||
|
ColumnDef::new(Location::CreatedAt)
|
||||||
|
.timestamp()
|
||||||
|
.default(SimpleExpr::Keyword(Keyword::CurrentTimestamp))
|
||||||
|
.not_null(),
|
||||||
|
)
|
||||||
|
.col(
|
||||||
|
ColumnDef::new(Location::UpdatedAt)
|
||||||
|
.timestamp()
|
||||||
|
.default(SimpleExpr::Keyword(Keyword::CurrentTimestamp))
|
||||||
|
.not_null(),
|
||||||
|
)
|
||||||
|
.to_owned(),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||||
|
manager
|
||||||
|
.drop_table(Table::drop().table(Location::Table).to_owned())
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user