proper fix plus delete artist actually removes files
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
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> {
|
||||
// Drop the unique index on artist name — different artists can share a name
|
||||
// (e.g., "Clara" the Italian singer and "Clara" the Brazilian singer)
|
||||
manager
|
||||
.drop_index(
|
||||
Index::drop()
|
||||
.name("idx_artists_name_unique")
|
||||
.table(Artists::Table)
|
||||
.to_owned(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
// Replace with a non-unique index for lookup performance
|
||||
manager
|
||||
.create_index(
|
||||
Index::create()
|
||||
.name("idx_artists_name")
|
||||
.table(Artists::Table)
|
||||
.col(Artists::Name)
|
||||
.to_owned(),
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||
manager
|
||||
.drop_index(
|
||||
Index::drop()
|
||||
.name("idx_artists_name")
|
||||
.table(Artists::Table)
|
||||
.to_owned(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
manager
|
||||
.create_index(
|
||||
Index::create()
|
||||
.name("idx_artists_name_unique")
|
||||
.table(Artists::Table)
|
||||
.col(Artists::Name)
|
||||
.unique()
|
||||
.to_owned(),
|
||||
)
|
||||
.await
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(DeriveIden)]
|
||||
enum Artists {
|
||||
Table,
|
||||
Name,
|
||||
}
|
||||
@@ -17,6 +17,7 @@ mod m20260320_000015_add_subsonic_password;
|
||||
mod m20260323_000016_remove_orphaned_artists;
|
||||
mod m20260323_000017_create_work_queue_and_scheduler;
|
||||
mod m20260324_000018_add_track_tagged;
|
||||
mod m20260325_000019_allow_duplicate_artist_names;
|
||||
|
||||
pub struct Migrator;
|
||||
|
||||
@@ -41,6 +42,7 @@ impl MigratorTrait for Migrator {
|
||||
Box::new(m20260323_000016_remove_orphaned_artists::Migration),
|
||||
Box::new(m20260323_000017_create_work_queue_and_scheduler::Migration),
|
||||
Box::new(m20260324_000018_add_track_tagged::Migration),
|
||||
Box::new(m20260325_000019_allow_duplicate_artist_names::Migration),
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user