init nginx related database schema

This commit is contained in:
GW_MC
2025-12-29 12:05:22 +08:00
parent c33e3aa0ca
commit 91d0e1cd7c
25 changed files with 1353 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
//! `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 = "access_list")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: Uuid,
pub name: String,
#[sea_orm(column_type = "Text", nullable)]
pub description: Option<String>,
pub created_by: Option<Uuid>,
pub created_at: DateTimeUtc,
pub updated_at: DateTimeUtc,
#[sea_orm(has_many)]
pub access_list_entries: HasMany<super::access_list_entry::Entity>,
#[sea_orm(has_many)]
pub proxy_host_access_lists: HasMany<super::proxy_host_access_list::Entity>,
#[sea_orm(has_many)]
pub stream_service_access_lists: HasMany<super::stream_service_access_list::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 {}

View File

@@ -0,0 +1,28 @@
//! `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 = "access_list_entry")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: Uuid,
pub access_list_id: Uuid,
pub entry_type: String,
pub value: String,
#[sea_orm(column_type = "Text", nullable)]
pub comment: Option<String>,
pub created_at: DateTimeUtc,
#[sea_orm(
belongs_to,
from = "access_list_id",
to = "id",
on_update = "Cascade",
on_delete = "Cascade"
)]
pub access_list: HasOne<super::access_list::Entity>,
}
impl ActiveModelBehavior for ActiveModel {}

View File

@@ -0,0 +1,29 @@
//! `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 = "audit_log")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: Uuid,
pub actor_id: Option<Uuid>,
pub action: String,
pub resource_type: String,
pub resource_id: String,
#[sea_orm(column_type = "JsonBinary", nullable)]
pub details: Option<Json>,
pub created_at: DateTimeUtc,
#[sea_orm(
belongs_to,
from = "actor_id",
to = "id",
on_update = "Cascade",
on_delete = "SetNull"
)]
pub user: HasOne<super::user::Entity>,
}
impl ActiveModelBehavior for ActiveModel {}

View File

@@ -0,0 +1,45 @@
//! `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_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 {}

View File

@@ -2,6 +2,15 @@
pub mod prelude;
pub mod access_list;
pub mod access_list_entry;
pub mod config;
pub mod location;
pub mod proxy_host;
pub mod proxy_host_access_list;
pub mod stream_service;
pub mod stream_service_access_list;
pub mod upstream;
pub mod upstream_target;
pub mod user;
pub mod user_identity;

View File

@@ -1,5 +1,14 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 2.0.0-rc.18
pub use super::access_list::Entity as AccessList;
pub use super::access_list_entry::Entity as AccessListEntry;
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::proxy_host_access_list::Entity as ProxyHostAccessList;
pub use super::stream_service::Entity as StreamService;
pub use super::stream_service_access_list::Entity as StreamServiceAccessList;
pub use super::upstream::Entity as Upstream;
pub use super::upstream_target::Entity as UpstreamTarget;
pub use super::user::Entity as User;
pub use super::user_identity::Entity as UserIdentity;

View File

@@ -0,0 +1,50 @@
//! `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(has_many)]
pub proxy_host_access_lists: HasMany<super::proxy_host_access_list::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 {}

View File

@@ -0,0 +1,33 @@
//! `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_access_list")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: Uuid,
pub proxy_host_id: Uuid,
pub access_list_id: Uuid,
pub created_at: DateTimeUtc,
#[sea_orm(
belongs_to,
from = "access_list_id",
to = "id",
on_update = "Cascade",
on_delete = "Cascade"
)]
pub access_list: HasOne<super::access_list::Entity>,
#[sea_orm(
belongs_to,
from = "proxy_host_id",
to = "id",
on_update = "Cascade",
on_delete = "Cascade"
)]
pub proxy_host: HasOne<super::proxy_host::Entity>,
}
impl ActiveModelBehavior for ActiveModel {}

View File

@@ -0,0 +1,47 @@
//! `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 = "stream_service")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: Uuid,
pub name: Option<String>,
pub listen_host: String,
pub listen_port: i64,
pub protocol: String,
pub mode: String,
pub forward_host: Option<String>,
pub forward_port: Option<i64>,
pub upstream_id: Option<Uuid>,
pub preserved_client_ip: bool,
pub enabled: bool,
#[sea_orm(column_type = "JsonBinary", nullable)]
pub meta: Option<Json>,
pub created_by: Option<Uuid>,
pub created_at: DateTimeUtc,
pub updated_at: DateTimeUtc,
#[sea_orm(has_many)]
pub stream_service_access_lists: HasMany<super::stream_service_access_list::Entity>,
#[sea_orm(
belongs_to,
from = "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 {}

View File

@@ -0,0 +1,33 @@
//! `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 = "stream_service_access_list")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: Uuid,
pub stream_service_id: Uuid,
pub access_list_id: Uuid,
pub created_at: DateTimeUtc,
#[sea_orm(
belongs_to,
from = "access_list_id",
to = "id",
on_update = "Cascade",
on_delete = "Cascade"
)]
pub access_list: HasOne<super::access_list::Entity>,
#[sea_orm(
belongs_to,
from = "stream_service_id",
to = "id",
on_update = "Cascade",
on_delete = "Cascade"
)]
pub stream_service: HasOne<super::stream_service::Entity>,
}
impl ActiveModelBehavior for ActiveModel {}

View File

@@ -0,0 +1,29 @@
//! `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 = "upstream")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: Uuid,
pub name: String,
pub protocol: String,
pub algorithm: String,
pub sticky_session: bool,
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(has_many)]
pub proxy_hosts: HasMany<super::proxy_host::Entity>,
#[sea_orm(has_many)]
pub stream_services: HasMany<super::stream_service::Entity>,
#[sea_orm(has_many)]
pub upstream_targets: HasMany<super::upstream_target::Entity>,
}
impl ActiveModelBehavior for ActiveModel {}

View File

@@ -0,0 +1,30 @@
//! `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 = "upstream_target")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: Uuid,
pub upstream_id: Uuid,
pub target_host: String,
pub target_port: i64,
pub weight: i64,
pub is_backup: bool,
pub enabled: bool,
pub created_at: DateTimeUtc,
pub updated_at: DateTimeUtc,
#[sea_orm(
belongs_to,
from = "upstream_id",
to = "id",
on_update = "Cascade",
on_delete = "Cascade"
)]
pub upstream: HasOne<super::upstream::Entity>,
}
impl ActiveModelBehavior for ActiveModel {}

View File

@@ -18,6 +18,12 @@ pub struct Model {
pub last_login_at: Option<DateTimeUtc>,
pub deleted_at: Option<DateTimeUtc>,
#[sea_orm(has_many)]
pub access_lists: HasMany<super::access_list::Entity>,
#[sea_orm(has_many)]
pub proxy_hosts: HasMany<super::proxy_host::Entity>,
#[sea_orm(has_many)]
pub stream_services: HasMany<super::stream_service::Entity>,
#[sea_orm(has_many)]
pub user_identities: HasMany<super::user_identity::Entity>,
}