fix: 修复重构引入的若干 bug (#126)

This commit is contained in:
ᴀᴍᴛᴏᴀᴇʀ
2024-07-04 01:00:41 +08:00
committed by GitHub
parent 940abd4f3b
commit ff1150e863
4 changed files with 10 additions and 24 deletions

View File

@@ -87,18 +87,10 @@ impl MigrationTrait for Migration {
.to_owned(),
)
.await?;
manager
.create_index(
Index::create()
.table(Video::Table)
.name("idx_video_cid_fid_bvid")
.col(Video::CollectionId)
.col(Video::FavoriteId)
.col(Video::Bvid)
.unique()
.to_owned(),
)
.await
// 在唯一索引中NULL 不等于 NULL所以需要使用 ifnull 函数排除空的情况
db.execute_unprepared("CREATE UNIQUE INDEX `idx_video_cid_fid_bvid` ON `video` (ifnull(`collection_id`, -1), ifnull(`favorite_id`, -1), `bvid`)")
.await?;
Ok(())
}
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {