Skip to content

Commit

Permalink
delete old album index even if we found the new one
Browse files Browse the repository at this point in the history
fixes #190
  • Loading branch information
sentriz committed Feb 12, 2022
1 parent e64524e commit 3dc838d
Showing 1 changed file with 1 addition and 13 deletions.
14 changes: 1 addition & 13 deletions server/db/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{},
)
Expand All @@ -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)
Expand Down

0 comments on commit 3dc838d

Please sign in to comment.