chore: 为 video sources 添加 enabled 字段 (#362)

This commit is contained in:
ᴀᴍᴛᴏᴀᴇʀ
2025-06-13 12:00:10 +08:00
committed by GitHub
parent a41efdbe78
commit a46c2572b1
6 changed files with 107 additions and 0 deletions

View File

@@ -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)]

View File

@@ -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)]

View File

@@ -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)]

View File

@@ -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)]

View File

@@ -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),
]
}
}

View File

@@ -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,
}