From 9cb42606ba21ae51b0643c92d1219061d2582e46 Mon Sep 17 00:00:00 2001 From: Deluan Date: Tue, 10 Mar 2020 17:23:02 -0400 Subject: [PATCH] fix: force full rescan to enable search by album artist --- ...0310171621_enable_search_by_albumartist.go | 21 +++++++++++++++++++ db/migration/migration.go | 9 ++++++++ 2 files changed, 30 insertions(+) create mode 100644 db/migration/20200310171621_enable_search_by_albumartist.go diff --git a/db/migration/20200310171621_enable_search_by_albumartist.go b/db/migration/20200310171621_enable_search_by_albumartist.go new file mode 100644 index 00000000000..8e18ab049b6 --- /dev/null +++ b/db/migration/20200310171621_enable_search_by_albumartist.go @@ -0,0 +1,21 @@ +package migration + +import ( + "database/sql" + + "github.com/pressly/goose" +) + +func init() { + goose.AddMigration(Up20200310171621, Down20200310171621) +} + +func Up20200310171621(tx *sql.Tx) error { + notice(tx, "A full rescan will be performed to enable search by Album Artist!") + return forceFullRescan(tx) +} + +func Down20200310171621(tx *sql.Tx) error { + // This code is executed when the migration is rolled back. + return nil +} diff --git a/db/migration/migration.go b/db/migration/migration.go index 19172245618..2c185f54865 100644 --- a/db/migration/migration.go +++ b/db/migration/migration.go @@ -20,6 +20,15 @@ NOTICE: %s } } +// Call this in migrations that requires a full rescan +func forceFullRescan(tx *sql.Tx) error { + _, err := tx.Exec(` +delete from property where id like 'LastScan%'; +update media_file set updated_at = '0001-01-01'; +`) + return err +} + var once sync.Once func isDBInitialized(tx *sql.Tx) (initialized bool) {