mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-05 04:53:01 +00:00
add migration to drop album and artist tables
This commit is contained in:
@@ -197,8 +197,6 @@ class SearchAll:
|
|||||||
itertools.groupby(mapped_items, lambda x: x["type"])
|
itertools.groupby(mapped_items, lambda x: x["type"])
|
||||||
]
|
]
|
||||||
|
|
||||||
print(len(groups))
|
|
||||||
|
|
||||||
# merge items of a group into a dict that looks like: {"albums": [album1, ...]}
|
# merge items of a group into a dict that looks like: {"albums": [album1, ...]}
|
||||||
groups = [
|
groups = [
|
||||||
{f"{group[0]['type']}s": [i['item'] for i in group]} for group in groups
|
{f"{group[0]['type']}s": [i['item'] for i in group]} for group in groups
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
Pre-init migrations are executed before the database is created.
|
Pre-init migrations are executed before the database is created.
|
||||||
Useful when you need to move files or folders before the database is created.
|
Useful when you need to move files or folders before the database is created.
|
||||||
|
|
||||||
|
`Example use cases: Moving files around, dropping tables, etc.`
|
||||||
|
|
||||||
PLEASE NOTE: OLDER MIGRATIONS CAN NEVER BE DELETED.
|
PLEASE NOTE: OLDER MIGRATIONS CAN NEVER BE DELETED.
|
||||||
ONLY MODIFY OLD MIGRATIONS FOR BUG FIXES OR ENHANCEMENTS ONLY.
|
ONLY MODIFY OLD MIGRATIONS FOR BUG FIXES OR ENHANCEMENTS ONLY.
|
||||||
[TRY NOT TO MODIFY BEHAVIOR, UNLESS YOU KNOW WHAT YOU'RE DOING].
|
[TRY NOT TO MODIFY BEHAVIOR, UNLESS YOU KNOW WHAT YOU'RE DOING].
|
||||||
@@ -11,9 +13,10 @@ from sqlite3 import OperationalError
|
|||||||
from app.db.sqlite.migrations import MigrationManager
|
from app.db.sqlite.migrations import MigrationManager
|
||||||
from app.logger import log
|
from app.logger import log
|
||||||
|
|
||||||
|
from .drop_artist_and_album_color_tables import DropArtistAndAlbumColorTables
|
||||||
from .move_to_xdg_folder import MoveToXdgFolder
|
from .move_to_xdg_folder import MoveToXdgFolder
|
||||||
|
|
||||||
all_preinits = [MoveToXdgFolder]
|
all_preinits = [MoveToXdgFolder, DropArtistAndAlbumColorTables]
|
||||||
|
|
||||||
|
|
||||||
def run_preinit_migrations():
|
def run_preinit_migrations():
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
"""
|
||||||
|
Another shot at attempting to fix duplicate album and artist color entries.
|
||||||
|
This release should finally fix the issue. The migration script will now remove
|
||||||
|
the album and artist color tables and recreate them.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from app.db.sqlite.utils import SQLiteManager
|
||||||
|
from app.logger import log
|
||||||
|
|
||||||
|
|
||||||
|
class DropArtistAndAlbumColorTables:
|
||||||
|
version = 2
|
||||||
|
name = "DropArtistAndAlbumColorTables"
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def migrate():
|
||||||
|
with SQLiteManager() as cur:
|
||||||
|
tables = ["artists", "albums"]
|
||||||
|
for table in tables:
|
||||||
|
cur.execute(f"DROP TABLE IF EXISTS {table}")
|
||||||
|
|
||||||
|
cur.execute("VACUUM")
|
||||||
|
|
||||||
|
log.info("Deleted artist and album color data to fix a few bugs. ✅")
|
||||||
Reference in New Issue
Block a user