mirror of
https://github.com/tcsenpai/swingmusic.git
synced 2025-06-07 03:35:35 +00:00

+ fix: sqlite3.ProgrammingError: Cannot operate on a closed cursor on ProcessAlbumColors() + move processing artist images from periodic_scans to Populate + bump hash string limit from 7 to 10 + add last_mod property to database + fix: TypeError: '<' not supported between instances of 'int' and 'str' on album page
46 lines
1.3 KiB
Python
46 lines
1.3 KiB
Python
"""
|
|
Pre-init migrations are executed 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.
|
|
ONLY MODIFY OLD MIGRATIONS FOR BUG FIXES OR ENHANCEMENTS ONLY.
|
|
[TRY NOT TO MODIFY BEHAVIOR, UNLESS YOU KNOW WHAT YOU'RE DOING].
|
|
"""
|
|
from sqlite3 import OperationalError
|
|
|
|
from app.db.sqlite.migrations import MigrationManager
|
|
from app.logger import log
|
|
|
|
from .drop_artist_and_album_color_tables import DropArtistAndAlbumColorTables
|
|
from .move_to_xdg_folder import MoveToXdgFolder
|
|
|
|
all_preinits = [MoveToXdgFolder, DropArtistAndAlbumColorTables]
|
|
|
|
|
|
def run_preinit_migrations():
|
|
"""
|
|
Runs all pre-init migrations.
|
|
"""
|
|
try:
|
|
userdb_version = MigrationManager.get_preinit_version()
|
|
except OperationalError:
|
|
userdb_version = 0
|
|
|
|
# No migrations to run
|
|
if userdb_version == 0:
|
|
return
|
|
|
|
for migration in all_preinits:
|
|
if migration.version > userdb_version:
|
|
log.warn("Running new pre-init migration: %s", migration.name)
|
|
migration.migrate()
|
|
|
|
|
|
def set_preinit_migration_versions():
|
|
"""
|
|
Sets the migration versions.
|
|
"""
|
|
MigrationManager.set_preinit_version(all_preinits[-1].version)
|