Make songs conflict on hash, not filename

This commit is contained in:
Agatha Lovelace 2022-09-24 13:37:36 +02:00
parent 0490795f02
commit bb9d2ce11f
Signed by: sorceress
GPG Key ID: 11BBCFC65FC9F401
2 changed files with 2 additions and 7 deletions

View File

@ -111,7 +111,7 @@ pub async fn index_source(source: Source, mode: IndexMode, db: &DatabaseConnecti
library::Entity::insert(song)
.on_conflict(
sea_query::OnConflict::column(library::Column::Filename)
sea_query::OnConflict::column(library::Column::Hash)
.do_nothing()
.to_owned(),
)

View File

@ -19,12 +19,7 @@ impl MigrationTrait for Migration {
.primary_key(),
)
.col(ColumnDef::new(Song::Path).string().not_null())
.col(
ColumnDef::new(Song::Filename)
.string()
.not_null()
.unique_key(),
)
.col(ColumnDef::new(Song::Filename).string().not_null())
.col(ColumnDef::new(Song::SourceId).integer().not_null())
.col(ColumnDef::new(Song::Hash).integer().not_null().unique_key())
.col(ColumnDef::new(Song::Artist).string())