From: Marcel van der Veldt Date: Thu, 16 Jun 2022 07:40:37 +0000 (+0200) Subject: Fix db error when migrating from old version (#368) X-Git-Url: https://git.kitaultman.com/?a=commitdiff_plain;h=3625c577c1e99d45ce947f8fa75225cfd559b6a5;p=music-assistant-server.git Fix db error when migrating from old version (#368) --- diff --git a/music_assistant/helpers/database.py b/music_assistant/helpers/database.py index 2541620f..dc440433 100755 --- a/music_assistant/helpers/database.py +++ b/music_assistant/helpers/database.py @@ -220,7 +220,7 @@ class Database: # always create db tables if they don't exist to prevent errors trying to access them later await self.__create_database_tables(db) - if prev_version < 15: + if prev_version < 17: # too many changes, just recreate await db.execute(f"DROP TABLE IF EXISTS {TABLE_ARTISTS}") await db.execute(f"DROP TABLE IF EXISTS {TABLE_ALBUMS}") @@ -233,20 +233,6 @@ class Database: # recreate missing tables await self.__create_database_tables(db) - if prev_version and prev_version < 16: - # album artist --> album artists - await db.execute(f"ALTER TABLE {TABLE_ALBUMS} ADD artists json;") - for db_row in await self.get_rows(TABLE_ALBUMS, db=db): - match = {"item_id": db_row["item_id"]} - new_values = {"artists": f'[{ db_row["artist"]}]'} - await self.update(TABLE_ALBUMS, match, new_values, db=db) - try: - await db.execute( - f"ALTER TABLE {TABLE_ALBUMS} DROP COLUMN artist;" - ) - except Exception: # pylint: disable=broad-except - pass # old sqlite version - # store current schema version await self.set_setting("version", str(SCHEMA_VERSION), db=db)