From 3dc838d36f0b69c454569fbf991f95e56902ba78 Mon Sep 17 00:00:00 2001 From: sentriz Date: Sat, 12 Feb 2022 16:53:06 +0000 Subject: [PATCH] delete old album index even if we found the new one fixes #190 --- server/db/migrations.go | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/server/db/migrations.go b/server/db/migrations.go index f284bb3..867841d 100644 --- a/server/db/migrations.go +++ b/server/db/migrations.go @@ -275,18 +275,6 @@ func migrateAlbumCreatedAt(tx *gorm.DB, _ MigrationContext) error { } func migrateAlbumRootDir(tx *gorm.DB, ctx MigrationContext) error { - var hasIDX int - tx. - Select("1"). - Table("sqlite_master"). - Where("type = ?", "index"). - Where("name = ?", "idx_album_abs_path"). - Count(&hasIDX) - if hasIDX == 1 { - // index already exists - return nil - } - step := tx.AutoMigrate( Album{}, ) @@ -301,7 +289,7 @@ func migrateAlbumRootDir(tx *gorm.DB, ctx MigrationContext) error { } step = tx.Exec(` - UPDATE albums SET root_dir=? + UPDATE albums SET root_dir=? WHERE root_dir IS NULL `, ctx.OriginalMusicPath) if err := step.Error; err != nil { return fmt.Errorf("step drop idx: %w", err)