From a46c2572b1cc49676b761309eaafff6057e99dba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=B4=80=E1=B4=8D=E1=B4=9B=E1=B4=8F=E1=B4=80=E1=B4=87?= =?UTF-8?q?=CA=80?= Date: Fri, 13 Jun 2025 12:00:10 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E4=B8=BA=20video=20sources=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20enabled=20=E5=AD=97=E6=AE=B5=20(#362)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/entities/collection.rs | 1 + .../bili_sync_entity/src/entities/favorite.rs | 1 + .../src/entities/submission.rs | 1 + .../src/entities/watch_later.rs | 1 + crates/bili_sync_migration/src/lib.rs | 2 + .../src/m20250612_090826_add_enabled.rs | 101 ++++++++++++++++++ 6 files changed, 107 insertions(+) create mode 100644 crates/bili_sync_migration/src/m20250612_090826_add_enabled.rs diff --git a/crates/bili_sync_entity/src/entities/collection.rs b/crates/bili_sync_entity/src/entities/collection.rs index 4272090..e38839e 100644 --- a/crates/bili_sync_entity/src/entities/collection.rs +++ b/crates/bili_sync_entity/src/entities/collection.rs @@ -14,6 +14,7 @@ pub struct Model { pub path: String, pub created_at: String, pub latest_row_at: DateTime, + pub enabled: bool, } #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] diff --git a/crates/bili_sync_entity/src/entities/favorite.rs b/crates/bili_sync_entity/src/entities/favorite.rs index be75351..56c1daf 100644 --- a/crates/bili_sync_entity/src/entities/favorite.rs +++ b/crates/bili_sync_entity/src/entities/favorite.rs @@ -13,6 +13,7 @@ pub struct Model { pub path: String, pub created_at: String, pub latest_row_at: DateTime, + pub enabled: bool, } #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] diff --git a/crates/bili_sync_entity/src/entities/submission.rs b/crates/bili_sync_entity/src/entities/submission.rs index 5cd7bb4..6937fb9 100644 --- a/crates/bili_sync_entity/src/entities/submission.rs +++ b/crates/bili_sync_entity/src/entities/submission.rs @@ -12,6 +12,7 @@ pub struct Model { pub path: String, pub created_at: String, pub latest_row_at: DateTime, + pub enabled: bool, } #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] diff --git a/crates/bili_sync_entity/src/entities/watch_later.rs b/crates/bili_sync_entity/src/entities/watch_later.rs index 615f016..da4986d 100644 --- a/crates/bili_sync_entity/src/entities/watch_later.rs +++ b/crates/bili_sync_entity/src/entities/watch_later.rs @@ -10,6 +10,7 @@ pub struct Model { pub path: String, pub created_at: String, pub latest_row_at: DateTime, + pub enabled: bool, } #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] diff --git a/crates/bili_sync_migration/src/lib.rs b/crates/bili_sync_migration/src/lib.rs index 7e82418..d415f13 100644 --- a/crates/bili_sync_migration/src/lib.rs +++ b/crates/bili_sync_migration/src/lib.rs @@ -5,6 +5,7 @@ mod m20240505_130850_add_collection; mod m20240709_130914_watch_later; mod m20240724_161008_submission; mod m20250122_062926_add_latest_row_at; +mod m20250612_090826_add_enabled; pub struct Migrator; @@ -17,6 +18,7 @@ impl MigratorTrait for Migrator { Box::new(m20240709_130914_watch_later::Migration), Box::new(m20240724_161008_submission::Migration), Box::new(m20250122_062926_add_latest_row_at::Migration), + Box::new(m20250612_090826_add_enabled::Migration), ] } } diff --git a/crates/bili_sync_migration/src/m20250612_090826_add_enabled.rs b/crates/bili_sync_migration/src/m20250612_090826_add_enabled.rs new file mode 100644 index 0000000..e5bb61d --- /dev/null +++ b/crates/bili_sync_migration/src/m20250612_090826_add_enabled.rs @@ -0,0 +1,101 @@ +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(WatchLater::Table) + .add_column(ColumnDef::new(WatchLater::Enabled).boolean().not_null().default(false)) + .to_owned(), + ) + .await?; + manager + .alter_table( + Table::alter() + .table(Submission::Table) + .add_column(ColumnDef::new(Submission::Enabled).boolean().not_null().default(false)) + .to_owned(), + ) + .await?; + manager + .alter_table( + Table::alter() + .table(Favorite::Table) + .add_column(ColumnDef::new(Favorite::Enabled).boolean().not_null().default(false)) + .to_owned(), + ) + .await?; + manager + .alter_table( + Table::alter() + .table(Collection::Table) + .add_column(ColumnDef::new(Collection::Enabled).boolean().not_null().default(false)) + .to_owned(), + ) + .await + } + + async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { + manager + .alter_table( + Table::alter() + .table(WatchLater::Table) + .drop_column(WatchLater::Enabled) + .to_owned(), + ) + .await?; + manager + .alter_table( + Table::alter() + .table(Submission::Table) + .drop_column(Submission::Enabled) + .to_owned(), + ) + .await?; + manager + .alter_table( + Table::alter() + .table(Favorite::Table) + .drop_column(Favorite::Enabled) + .to_owned(), + ) + .await?; + manager + .alter_table( + Table::alter() + .table(Collection::Table) + .drop_column(Collection::Enabled) + .to_owned(), + ) + .await + } +} + +#[derive(DeriveIden)] +enum WatchLater { + Table, + Enabled, +} + +#[derive(DeriveIden)] +enum Submission { + Table, + Enabled, +} + +#[derive(DeriveIden)] +enum Favorite { + Table, + Enabled, +} + +#[derive(DeriveIden)] +enum Collection { + Table, + Enabled, +}