From f4a5c2fb3dfa823193db9728f208f23af1c527a2 Mon Sep 17 00:00:00 2001 From: krateng Date: Tue, 20 Feb 2024 16:36:57 +0100 Subject: [PATCH] Add some DB maintenance --- maloja/database/sqldb.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/maloja/database/sqldb.py b/maloja/database/sqldb.py index bdc73f4..a51c3e7 100644 --- a/maloja/database/sqldb.py +++ b/maloja/database/sqldb.py @@ -1705,6 +1705,11 @@ def clean_db(dbconn=None): log(f"Database Cleanup...") to_delete = [ + # NULL associations + "from albumartists where album_id is NULL", + "from albumartists where artist_id is NULL", + "from trackartists where track_id is NULL", + "from trackartists where artist_id is NULL", # tracks with no scrobbles (trackartist entries first) "from trackartists where track_id in (select id from tracks where id not in (select track_id from scrobbles))", "from tracks where id not in (select track_id from scrobbles)",