API_SCHEMA_VERSION: Final[int] = 23
MIN_SCHEMA_VERSION: Final[int] = 23
-DB_SCHEMA_VERSION: Final[int] = 26
+DB_SCHEMA_VERSION: Final[int] = 27
ROOT_LOGGER_NAME: Final[str] = "music_assistant"
await asyncio.to_thread(shutil.copyfile, db_path, db_path_backup)
# handle db migration from previous schema to this one
- if prev_version == DB_SCHEMA_VERSION - 1:
+ if prev_version == 25:
self.logger.info(
"Performing database migration from %s to %s",
prev_version,
DB_TABLE_ARTISTS,
DB_TABLE_ALBUMS,
DB_TABLE_TRACKS,
+ DB_TABLE_PLAYLISTS,
+ DB_TABLE_RADIOS,
):
# create new external_ids column
await self.database.execute(
"Database migration to version %s completed",
DB_SCHEMA_VERSION,
)
+ elif prev_version == 26:
+ self.logger.info(
+ "Performing database migration from %s to %s",
+ prev_version,
+ DB_SCHEMA_VERSION,
+ )
+ # migrate playlists and radios tables which we forgot to migrate in schema 26
+ for table in (
+ DB_TABLE_PLAYLISTS,
+ DB_TABLE_RADIOS,
+ ):
+ # create new external_ids column
+ await self.database.execute(
+ f"ALTER TABLE {table} "
+ "ADD COLUMN external_ids "
+ "json NOT NULL DEFAULT '[]'"
+ )
# handle all other schema versions
else:
# we keep it simple and just recreate the tables
return mb_artist.id
# last restort: track matching by name
for ref_track in ref_tracks:
+ if not ref_track.album:
+ continue
if result := await self.search(
artistname=artist.name,
albumname=ref_track.album.name,