add guard for missing db schema migration
authorMarcel van der Veldt <m.vanderveldt@outlook.com>
Mon, 3 Apr 2023 14:33:18 +0000 (16:33 +0200)
committerMarcel van der Veldt <m.vanderveldt@outlook.com>
Mon, 3 Apr 2023 14:33:18 +0000 (16:33 +0200)
music_assistant/server/controllers/music.py

index dfe34f6d2e8755f0fb660d2dbeff1ef58ff6627f..e36b31c75b5b6d17322462d1a5ce8b4be8f4b0c2 100755 (executable)
@@ -594,8 +594,8 @@ class MusicController:
                 SCHEMA_VERSION,
             )
 
-            if prev_version < SCHEMA_VERSION:
-                # for now just keep it simple and just recreate the tables
+            if prev_version < 22:
+                # for now just keep it simple and just recreate the tables if the schema is too old
                 await self.database.execute(f"DROP TABLE IF EXISTS {DB_TABLE_ARTISTS}")
                 await self.database.execute(f"DROP TABLE IF EXISTS {DB_TABLE_ALBUMS}")
                 await self.database.execute(f"DROP TABLE IF EXISTS {DB_TABLE_TRACKS}")
@@ -604,6 +604,8 @@ class MusicController:
 
                 # recreate missing tables
                 await self.__create_database_tables()
+            else:
+                raise RuntimeError("db schema migration missing")
 
         # store current schema version
         await self.database.insert_or_replace(