feature/upstream-service #13

Merged
GW_MC merged 43 commits from feature/upstream-service into master 2026-01-01 10:49:32 +08:00
24 changed files with 156 additions and 935 deletions
Showing only changes of commit b43f9fcb00 - Show all commits

View File

@@ -1,34 +0,0 @@
//! `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

@@ -1,28 +0,0 @@
//! `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

@@ -5,25 +5,26 @@ use serde::{Deserialize, Serialize};
#[sea_orm::model]
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Serialize, Deserialize)]
#[sea_orm(table_name = "audit_log")]
#[sea_orm(table_name = "edit_operation")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: Uuid,
pub actor_id: Option<Uuid>,
pub action: String,
pub session_id: Uuid,
pub resource_type: String,
pub resource_id: String,
#[sea_orm(column_type = "JsonBinary", nullable)]
pub details: Option<Json>,
pub resource_id: Option<Uuid>,
pub operation_type: String,
#[sea_orm(column_type = "JsonBinary")]
pub payload: Json,
pub created_at: DateTimeUtc,
pub applied_at: Option<DateTimeUtc>,
#[sea_orm(
belongs_to,
from = "actor_id",
from = "session_id",
to = "id",
on_update = "Cascade",
on_delete = "SetNull"
on_delete = "Cascade"
)]
pub user: HasOne<super::user::Entity>,
pub editing_session: HasOne<super::editing_session::Entity>,
}
impl ActiveModelBehavior for ActiveModel {}

View File

@@ -0,0 +1,23 @@
//! `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 = "editing_session")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: Uuid,
pub name: Option<String>,
pub created_by: Option<Uuid>,
pub status: String,
pub created_at: DateTimeUtc,
pub applied_at: Option<DateTimeUtc>,
pub applied_by: Option<Uuid>,
pub expires_at: Option<DateTimeUtc>,
#[sea_orm(has_many)]
pub edit_operations: HasMany<super::edit_operation::Entity>,
}
impl ActiveModelBehavior for ActiveModel {}

View File

@@ -1,45 +0,0 @@
//! `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,14 +2,9 @@
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 edit_operation;
pub mod editing_session;
pub mod upstream;
pub mod upstream_target;
pub mod user;

View File

@@ -1,13 +1,8 @@
//! `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::edit_operation::Entity as EditOperation;
pub use super::editing_session::Entity as EditingSession;
pub use super::upstream::Entity as Upstream;
pub use super::upstream_target::Entity as UpstreamTarget;
pub use super::user::Entity as User;

View File

@@ -1,50 +0,0 @@
//! `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

@@ -1,33 +0,0 @@
//! `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

@@ -1,29 +0,0 @@
//! `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 = "session")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: Uuid,
pub user_id: Uuid,
#[sea_orm(unique)]
pub refresh_token_hash: Option<String>,
pub expires_at: DateTimeUtc,
pub revoked_at: Option<DateTimeUtc>,
pub created_at: DateTimeUtc,
pub updated_at: DateTimeUtc,
#[sea_orm(
belongs_to,
from = "user_id",
to = "id",
on_update = "Cascade",
on_delete = "Cascade"
)]
pub user: HasOne<super::user::Entity>,
}
impl ActiveModelBehavior for ActiveModel {}

View File

@@ -1,47 +0,0 @@
//! `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

@@ -1,33 +0,0 @@
//! `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

@@ -17,12 +17,6 @@ pub struct Model {
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>,
}

View File

@@ -18,12 +18,6 @@ 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>,
}

View File

@@ -15,13 +15,7 @@ impl MigratorTrait for Migrator {
Box::new(m20251011_000003_create_user_identity_table::Migration),
Box::new(m20251223_000004_create_upstream_table::Migration),
Box::new(m20251223_000005_create_upstream_target_table::Migration),
Box::new(m20251223_000006_create_proxy_host_table::Migration),
Box::new(m20251223_000007_create_location_table::Migration),
Box::new(m20251223_000008_create_stream_service_table::Migration),
Box::new(m20251223_000009_create_access_list_table::Migration),
Box::new(m20251223_000010_create_access_list_entry_table::Migration),
Box::new(m20251223_000011_create_proxy_host_access_list_table::Migration),
Box::new(m20251223_000012_create_stream_service_access_list_table::Migration),
Box::new(m20251230_000006_create_editing_session_table::Migration),
]
}
}

View File

@@ -3,10 +3,4 @@ pub mod m20251011_000002_create_user_table;
pub mod m20251011_000003_create_user_identity_table;
pub mod m20251223_000004_create_upstream_table;
pub mod m20251223_000005_create_upstream_target_table;
pub mod m20251223_000006_create_proxy_host_table;
pub mod m20251223_000007_create_location_table;
pub mod m20251223_000008_create_stream_service_table;
pub mod m20251223_000009_create_access_list_table;
pub mod m20251223_000010_create_access_list_entry_table;
pub mod m20251223_000011_create_proxy_host_access_list_table;
pub mod m20251223_000012_create_stream_service_access_list_table;
pub mod m20251230_000006_create_editing_session_table;

View File

@@ -1,124 +0,0 @@
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
}
}

View File

@@ -1,100 +0,0 @@
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,
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::m20251223_000006_create_proxy_host_table::ProxyHost::Table,
super::m20251223_000006_create_proxy_host_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::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
}
}

View File

@@ -1,112 +0,0 @@
use sea_orm_migration::{prelude::*, schema::*};
#[derive(DeriveMigrationName)]
pub struct Migration;
#[forbid(dead_code)]
#[derive(DeriveIden)]
pub enum StreamService {
Table,
Id,
Name,
ListenHost,
ListenPort,
Protocol,
Mode,
ForwardHost,
ForwardPort,
UpstreamId,
PreservedClientIp,
Enabled,
Meta,
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(StreamService::Table)
.if_not_exists()
.col(pk_uuid(StreamService::Id))
.col(ColumnDef::new(StreamService::Name).string().null())
.col(
ColumnDef::new(StreamService::ListenHost)
.string()
.default("0.0.0.0")
.not_null(),
)
.col(ColumnDef::new(StreamService::ListenPort).integer().not_null())
.col(ColumnDef::new(StreamService::Protocol).string().not_null())
.col(
ColumnDef::new(StreamService::Mode)
.string()
.default("direct")
.not_null(),
)
.col(ColumnDef::new(StreamService::ForwardHost).string().null())
.col(ColumnDef::new(StreamService::ForwardPort).integer().null())
.col(ColumnDef::new(StreamService::UpstreamId).uuid().null())
.foreign_key(
ForeignKey::create()
.name("fk-stream-service-upstream-id")
.from(StreamService::Table, StreamService::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(StreamService::PreservedClientIp)
.boolean()
.default(false)
.not_null(),
)
.col(
ColumnDef::new(StreamService::Enabled)
.boolean()
.default(true)
.not_null(),
)
.col(ColumnDef::new(StreamService::Meta).json_binary().null())
.col(ColumnDef::new(StreamService::CreatedBy).uuid().null())
.foreign_key(
ForeignKey::create()
.name("fk-stream-service-created-by")
.from(StreamService::Table, StreamService::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(StreamService::CreatedAt)
.timestamp()
.default(SimpleExpr::Keyword(Keyword::CurrentTimestamp))
.not_null(),
)
.col(
ColumnDef::new(StreamService::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(StreamService::Table).to_owned())
.await
}
}

View File

@@ -1,63 +0,0 @@
use sea_orm_migration::{prelude::*, schema::*};
#[derive(DeriveMigrationName)]
pub struct Migration;
#[forbid(dead_code)]
#[derive(DeriveIden)]
pub enum AccessList {
Table,
Id,
Name,
Description,
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(AccessList::Table)
.if_not_exists()
.col(pk_uuid(AccessList::Id))
.col(ColumnDef::new(AccessList::Name).string().not_null())
.col(ColumnDef::new(AccessList::Description).text().null())
.col(ColumnDef::new(AccessList::CreatedBy).uuid().null())
.foreign_key(
ForeignKey::create()
.name("fk-access-list-created-by")
.from(AccessList::Table, AccessList::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(AccessList::CreatedAt)
.timestamp()
.default(SimpleExpr::Keyword(Keyword::CurrentTimestamp))
.not_null(),
)
.col(
ColumnDef::new(AccessList::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(AccessList::Table).to_owned())
.await
}
}

View File

@@ -1,58 +0,0 @@
use sea_orm_migration::{prelude::*, schema::*};
#[derive(DeriveMigrationName)]
pub struct Migration;
#[forbid(dead_code)]
#[derive(DeriveIden)]
pub enum AccessListEntry {
Table,
Id,
AccessListId,
EntryType,
Value,
Comment,
CreatedAt,
}
#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.create_table(
Table::create()
.table(AccessListEntry::Table)
.if_not_exists()
.col(pk_uuid(AccessListEntry::Id))
.col(ColumnDef::new(AccessListEntry::AccessListId).uuid().not_null())
.foreign_key(
ForeignKey::create()
.name("fk-access-list-entry-access-list-id")
.from(AccessListEntry::Table, AccessListEntry::AccessListId)
.to(
super::m20251223_000009_create_access_list_table::AccessList::Table,
super::m20251223_000009_create_access_list_table::AccessList::Id,
)
.on_delete(ForeignKeyAction::Cascade)
.on_update(ForeignKeyAction::Cascade),
)
.col(ColumnDef::new(AccessListEntry::EntryType).string().not_null())
.col(ColumnDef::new(AccessListEntry::Value).string().not_null())
.col(ColumnDef::new(AccessListEntry::Comment).text().null())
.col(
ColumnDef::new(AccessListEntry::CreatedAt)
.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(AccessListEntry::Table).to_owned())
.await
}
}

View File

@@ -1,65 +0,0 @@
use sea_orm_migration::{prelude::*, schema::*};
#[derive(DeriveMigrationName)]
pub struct Migration;
#[forbid(dead_code)]
#[derive(DeriveIden)]
pub enum ProxyHostAccessList {
Table,
Id,
ProxyHostId,
AccessListId,
CreatedAt,
}
#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.create_table(
Table::create()
.table(ProxyHostAccessList::Table)
.if_not_exists()
.col(pk_uuid(ProxyHostAccessList::Id))
.col(ColumnDef::new(ProxyHostAccessList::ProxyHostId).uuid().not_null())
.foreign_key(
ForeignKey::create()
.name("fk-proxy-host-access-list-host-id")
.from(ProxyHostAccessList::Table, ProxyHostAccessList::ProxyHostId)
.to(
super::m20251223_000006_create_proxy_host_table::ProxyHost::Table,
super::m20251223_000006_create_proxy_host_table::ProxyHost::Id,
)
.on_delete(ForeignKeyAction::Cascade)
.on_update(ForeignKeyAction::Cascade),
)
.col(ColumnDef::new(ProxyHostAccessList::AccessListId).uuid().not_null())
.foreign_key(
ForeignKey::create()
.name("fk-proxy-host-access-list-access-list-id")
.from(ProxyHostAccessList::Table, ProxyHostAccessList::AccessListId)
.to(
super::m20251223_000009_create_access_list_table::AccessList::Table,
super::m20251223_000009_create_access_list_table::AccessList::Id,
)
.on_delete(ForeignKeyAction::Cascade)
.on_update(ForeignKeyAction::Cascade),
)
.col(
ColumnDef::new(ProxyHostAccessList::CreatedAt)
.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(ProxyHostAccessList::Table).to_owned())
.await
}
}

View File

@@ -1,65 +0,0 @@
use sea_orm_migration::{prelude::*, schema::*};
#[derive(DeriveMigrationName)]
pub struct Migration;
#[forbid(dead_code)]
#[derive(DeriveIden)]
pub enum StreamServiceAccessList {
Table,
Id,
StreamServiceId,
AccessListId,
CreatedAt,
}
#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.create_table(
Table::create()
.table(StreamServiceAccessList::Table)
.if_not_exists()
.col(pk_uuid(StreamServiceAccessList::Id))
.col(ColumnDef::new(StreamServiceAccessList::StreamServiceId).uuid().not_null())
.foreign_key(
ForeignKey::create()
.name("fk-stream-service-access-list-service-id")
.from(StreamServiceAccessList::Table, StreamServiceAccessList::StreamServiceId)
.to(
super::m20251223_000008_create_stream_service_table::StreamService::Table,
super::m20251223_000008_create_stream_service_table::StreamService::Id,
)
.on_delete(ForeignKeyAction::Cascade)
.on_update(ForeignKeyAction::Cascade),
)
.col(ColumnDef::new(StreamServiceAccessList::AccessListId).uuid().not_null())
.foreign_key(
ForeignKey::create()
.name("fk-stream-service-access-list-access-list-id")
.from(StreamServiceAccessList::Table, StreamServiceAccessList::AccessListId)
.to(
super::m20251223_000009_create_access_list_table::AccessList::Table,
super::m20251223_000009_create_access_list_table::AccessList::Id,
)
.on_delete(ForeignKeyAction::Cascade)
.on_update(ForeignKeyAction::Cascade),
)
.col(
ColumnDef::new(StreamServiceAccessList::CreatedAt)
.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(StreamServiceAccessList::Table).to_owned())
.await
}
}

View File

@@ -0,0 +1,117 @@
use sea_orm_migration::{prelude::*, schema::*};
#[derive(DeriveMigrationName)]
pub struct Migration;
#[forbid(dead_code)]
#[derive(DeriveIden)]
pub enum EditingSession {
Table,
Id,
Name,
CreatedBy,
Status,
CreatedAt,
AppliedAt,
AppliedBy,
ExpiresAt,
}
#[forbid(dead_code)]
#[derive(DeriveIden)]
pub enum EditOperation {
Table,
Id,
SessionId,
ResourceType,
ResourceId,
OperationType,
Payload,
CreatedAt,
AppliedAt,
}
#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.create_table(
Table::create()
.table(EditingSession::Table)
.if_not_exists()
.col(pk_uuid(EditingSession::Id))
.col(ColumnDef::new(EditingSession::Name).string().null())
.col(ColumnDef::new(EditingSession::CreatedBy).uuid().null())
.col(
ColumnDef::new(EditingSession::Status)
.string()
.default("pending")
.not_null(),
)
.col(
ColumnDef::new(EditingSession::CreatedAt)
.timestamp()
.default(SimpleExpr::Keyword(Keyword::CurrentTimestamp))
.not_null(),
)
.col(ColumnDef::new(EditingSession::AppliedAt).timestamp().null())
.col(ColumnDef::new(EditingSession::AppliedBy).uuid().null())
.col(ColumnDef::new(EditingSession::ExpiresAt).timestamp().null())
.to_owned(),
)
.await?;
manager
.create_table(
Table::create()
.table(EditOperation::Table)
.if_not_exists()
.col(pk_uuid(EditOperation::Id))
.col(ColumnDef::new(EditOperation::SessionId).uuid().not_null())
.col(
ColumnDef::new(EditOperation::ResourceType)
.string()
.not_null(),
) // e.g. "upstream", "location"
.col(ColumnDef::new(EditOperation::ResourceId).uuid().null()) // null for create
.col(
ColumnDef::new(EditOperation::OperationType)
.string()
.not_null(),
) // "create"|"update"|"delete"
.col(
ColumnDef::new(EditOperation::Payload)
.json_binary()
.not_null(),
) // patch or full object
.col(
ColumnDef::new(EditOperation::CreatedAt)
.timestamp()
.default(SimpleExpr::Keyword(Keyword::CurrentTimestamp))
.not_null(),
)
.col(ColumnDef::new(EditOperation::AppliedAt).timestamp().null())
.foreign_key(
ForeignKey::create()
.name("fk-edit-op-session")
.from(EditOperation::Table, EditOperation::SessionId)
.to(EditingSession::Table, EditingSession::Id)
.on_delete(ForeignKeyAction::Cascade)
.on_update(ForeignKeyAction::Cascade),
)
.to_owned(),
)
.await?;
Ok(())
}
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.drop_table(Table::drop().table(EditOperation::Table).to_owned())
.await?;
manager
.drop_table(Table::drop().table(EditingSession::Table).to_owned())
.await
}
}