mirror of
https://github.com/amtoaer/bili-sync.git
synced 2026-09-04 23:18:02 +08:00
feat: 迁移所有配置到数据库,并支持运行时重载 (#364)
This commit is contained in:
@@ -6,6 +6,7 @@ mod m20240709_130914_watch_later;
|
||||
mod m20240724_161008_submission;
|
||||
mod m20250122_062926_add_latest_row_at;
|
||||
mod m20250612_090826_add_enabled;
|
||||
mod m20250613_043257_add_config;
|
||||
|
||||
pub struct Migrator;
|
||||
|
||||
@@ -19,6 +20,7 @@ impl MigratorTrait for Migrator {
|
||||
Box::new(m20240724_161008_submission::Migration),
|
||||
Box::new(m20250122_062926_add_latest_row_at::Migration),
|
||||
Box::new(m20250612_090826_add_enabled::Migration),
|
||||
Box::new(m20250613_043257_add_config::Migration),
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
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(Config::Table)
|
||||
.if_not_exists()
|
||||
.col(
|
||||
ColumnDef::new(Config::Id)
|
||||
.integer()
|
||||
.not_null()
|
||||
.auto_increment()
|
||||
.primary_key(),
|
||||
)
|
||||
.col(ColumnDef::new(Config::Data).text().not_null())
|
||||
.col(
|
||||
ColumnDef::new(Config::CreatedAt)
|
||||
.timestamp()
|
||||
.default(Expr::current_timestamp())
|
||||
.not_null(),
|
||||
)
|
||||
.to_owned(),
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||
manager.drop_table(Table::drop().table(Config::Table).to_owned()).await
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(DeriveIden)]
|
||||
enum Config {
|
||||
Table,
|
||||
Id,
|
||||
Data,
|
||||
CreatedAt,
|
||||
}
|
||||
Reference in New Issue
Block a user