mirror of
https://github.com/house-of-vanity/OutFleet.git
synced 2025-12-19 02:37:53 +00:00
Added telegram
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
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(TelegramConfig::Table)
|
||||
.if_not_exists()
|
||||
.col(ColumnDef::new(TelegramConfig::Id)
|
||||
.uuid()
|
||||
.not_null()
|
||||
.primary_key())
|
||||
.col(ColumnDef::new(TelegramConfig::BotToken)
|
||||
.string()
|
||||
.not_null())
|
||||
.col(ColumnDef::new(TelegramConfig::IsActive)
|
||||
.boolean()
|
||||
.not_null()
|
||||
.default(false))
|
||||
.col(ColumnDef::new(TelegramConfig::CreatedAt)
|
||||
.timestamp_with_time_zone()
|
||||
.not_null())
|
||||
.col(ColumnDef::new(TelegramConfig::UpdatedAt)
|
||||
.timestamp_with_time_zone()
|
||||
.not_null())
|
||||
.to_owned(),
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||
manager
|
||||
.drop_table(Table::drop().table(TelegramConfig::Table).to_owned())
|
||||
.await
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Iden)]
|
||||
pub enum TelegramConfig {
|
||||
Table,
|
||||
Id,
|
||||
BotToken,
|
||||
IsActive,
|
||||
CreatedAt,
|
||||
UpdatedAt,
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
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
|
||||
.alter_table(
|
||||
Table::alter()
|
||||
.table(Users::Table)
|
||||
.add_column(
|
||||
ColumnDef::new(Users::IsTelegramAdmin)
|
||||
.boolean()
|
||||
.not_null()
|
||||
.default(false)
|
||||
)
|
||||
.to_owned(),
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||
manager
|
||||
.alter_table(
|
||||
Table::alter()
|
||||
.table(Users::Table)
|
||||
.drop_column(Users::IsTelegramAdmin)
|
||||
.to_owned(),
|
||||
)
|
||||
.await
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Iden)]
|
||||
enum Users {
|
||||
Table,
|
||||
IsTelegramAdmin,
|
||||
}
|
||||
@@ -10,6 +10,8 @@ mod m20241201_000007_create_inbound_users_table;
|
||||
mod m20250919_000001_update_inbound_users_schema;
|
||||
mod m20250922_000001_add_grpc_hostname_to_servers;
|
||||
mod m20250923_000001_create_dns_providers_table;
|
||||
mod m20250929_000001_create_telegram_config_table;
|
||||
mod m20250929_000002_add_telegram_admin_to_users;
|
||||
|
||||
pub struct Migrator;
|
||||
|
||||
@@ -27,6 +29,8 @@ impl MigratorTrait for Migrator {
|
||||
Box::new(m20250919_000001_update_inbound_users_schema::Migration),
|
||||
Box::new(m20250922_000001_add_grpc_hostname_to_servers::Migration),
|
||||
Box::new(m20250923_000001_create_dns_providers_table::Migration),
|
||||
Box::new(m20250929_000001_create_telegram_config_table::Migration),
|
||||
Box::new(m20250929_000002_add_telegram_admin_to_users::Migration),
|
||||
]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user