mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-03 20:13:02 +00:00
write sample migration structure
This commit is contained in:
@@ -1,3 +1,20 @@
|
|||||||
"""
|
"""
|
||||||
Migrations module
|
Migrations module.
|
||||||
|
|
||||||
|
Reads and applies the latest database migrations.
|
||||||
"""
|
"""
|
||||||
|
from .main import main_db_migrations
|
||||||
|
from .userdata import userdata_db_migrations
|
||||||
|
|
||||||
|
|
||||||
|
def apply_migrations():
|
||||||
|
userdb_version = 0
|
||||||
|
maindb_version = 0
|
||||||
|
|
||||||
|
for migration in main_db_migrations:
|
||||||
|
if migration.version > maindb_version:
|
||||||
|
migration.migrate()
|
||||||
|
|
||||||
|
for migration in userdata_db_migrations:
|
||||||
|
if migration.version > userdb_version:
|
||||||
|
migration.migrate()
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
from .sample import SampleMigrationModel
|
||||||
|
|
||||||
|
main_db_migrations = [SampleMigrationModel]
|
||||||
|
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
class SampleMigrationModel:
|
||||||
|
version = 1
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def migrate():
|
||||||
|
print("executing sample main db migration")
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
from .sample import SampleMigrationModel
|
||||||
|
|
||||||
|
userdata_db_migrations = [SampleMigrationModel]
|
||||||
|
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
class SampleMigrationModel:
|
||||||
|
version = 1
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def migrate():
|
||||||
|
print("executing sample userdata db migration")
|
||||||
@@ -10,13 +10,13 @@ from app.db.sqlite import create_connection, create_tables, queries
|
|||||||
from app.db.store import Store
|
from app.db.store import Store
|
||||||
from app.settings import APP_DB_PATH, USERDATA_DB_PATH
|
from app.settings import APP_DB_PATH, USERDATA_DB_PATH
|
||||||
from app.utils import get_home_res_path
|
from app.utils import get_home_res_path
|
||||||
|
from app.migrations import apply_migrations
|
||||||
|
|
||||||
config = ConfigParser()
|
config = ConfigParser()
|
||||||
|
|
||||||
config_path = get_home_res_path("pyinstaller.config.ini")
|
config_path = get_home_res_path("pyinstaller.config.ini")
|
||||||
config.read(config_path)
|
config.read(config_path)
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
IS_BUILD = config["DEFAULT"]["BUILD"] == "True"
|
IS_BUILD = config["DEFAULT"]["BUILD"] == "True"
|
||||||
except KeyError:
|
except KeyError:
|
||||||
@@ -112,6 +112,8 @@ def setup_sqlite():
|
|||||||
app_db_conn.close()
|
app_db_conn.close()
|
||||||
playlist_db_conn.close()
|
playlist_db_conn.close()
|
||||||
|
|
||||||
|
apply_migrations()
|
||||||
|
|
||||||
Store.load_all_tracks()
|
Store.load_all_tracks()
|
||||||
Store.process_folders()
|
Store.process_folders()
|
||||||
Store.load_albums()
|
Store.load_albums()
|
||||||
|
|||||||
Reference in New Issue
Block a user