From: Marcel van der Veldt Date: Mon, 9 May 2022 11:18:13 +0000 (+0200) Subject: fix database setup X-Git-Url: https://git.kitaultman.com/?a=commitdiff_plain;h=a71d4910b363930ca83afd4bdebe8718fb524d3c;p=music-assistant-server.git fix database setup --- diff --git a/music_assistant/helpers/database.py b/music_assistant/helpers/database.py index 49db8b8e..7c66ed72 100755 --- a/music_assistant/helpers/database.py +++ b/music_assistant/helpers/database.py @@ -182,6 +182,8 @@ class Database: prev_version, SCHEMA_VERSION, ) + # 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 < 4: # schema version 3: too many breaking changes, rebuild db @@ -192,20 +194,24 @@ class Database: await db.execute(f"DROP TABLE IF EXISTS {TABLE_RADIOS}") await db.execute(f"DROP TABLE IF EXISTS {TABLE_PROV_MAPPINGS}") await db.execute(f"DROP TABLE IF EXISTS {TABLE_CACHE}") + # recreate missing tables + await self.__create_database_tables(db) if prev_version < 5: # delete player_settings table: use generic settings table instead await db.execute("DROP TABLE IF EXISTS queue_settings") + # recreate table + await self.__create_database_tables(db) if prev_version < 6: # recreate radio items due to some changes await db.execute(f"DROP TABLE IF EXISTS {TABLE_RADIOS}") + # recreate table + await self.__create_database_tables(db) match = {"media_type": "radio"} if await self.get_count(TABLE_PROV_MAPPINGS, match): await self.delete(TABLE_PROV_MAPPINGS, match, db=db) - # create db tables - await self.__create_database_tables(db) # store current schema version await self.set_setting("version", str(SCHEMA_VERSION), db=db)