Add one-time migration to purge stale Deezer metadata cache
Deezer album entries cached from /artist/{id}/albums lack artist info,
and track entries from search results lack track_position. Purges all
Deezer album/track cache entries on first startup so they repopulate
with complete data.
This commit is contained in:
parent
bbaa897cd2
commit
df14bbf745
1 changed files with 17 additions and 0 deletions
|
|
@ -568,6 +568,23 @@ class MusicDatabase:
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
# One-time migration: purge Deezer album/track cache entries with missing data.
|
||||||
|
# Deezer's /artist/{id}/albums returns albums without artist info, and search
|
||||||
|
# results cache tracks without track_position — both produce bad metadata.
|
||||||
|
try:
|
||||||
|
cursor.execute("SELECT name FROM sqlite_master WHERE type='table' AND name='_deezer_cache_v2_migrated'")
|
||||||
|
if not cursor.fetchone():
|
||||||
|
cursor.execute("""DELETE FROM metadata_cache_entities
|
||||||
|
WHERE source = 'deezer' AND entity_type IN ('album', 'track')""")
|
||||||
|
purged = cursor.rowcount
|
||||||
|
cursor.execute("""DELETE FROM metadata_cache_searches
|
||||||
|
WHERE source = 'deezer' AND search_type IN ('album', 'track')""")
|
||||||
|
cursor.execute("CREATE TABLE _deezer_cache_v2_migrated (applied_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP)")
|
||||||
|
if purged > 0:
|
||||||
|
logger.info(f"Purged {purged} stale Deezer cache entries (missing artist/track_position)")
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
conn.commit()
|
conn.commit()
|
||||||
logger.info("Database initialized successfully")
|
logger.info("Database initialized successfully")
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue