diff options
author | morpheus65535 <[email protected]> | 2021-06-19 00:03:40 -0400 |
---|---|---|
committer | morpheus65535 <[email protected]> | 2021-06-19 00:03:40 -0400 |
commit | 50d4a7a0479751fa2bd67058ec0266093970ddbc (patch) | |
tree | 03acc84a371f0cd777289e089920d62627508067 | |
parent | fd6c959ec8baed6a13619f0df5ab404e6dd99b61 (diff) | |
download | bazarr-0.9.6-beta.29.tar.gz bazarr-0.9.6-beta.29.zip |
Implemented database migration functionv0.9.6-beta.29
-rw-r--r-- | bazarr/database.py | 46 | ||||
-rw-r--r-- | bazarr/init.py | 3 | ||||
-rw-r--r-- | bazarr/logger.py | 4 |
3 files changed, 50 insertions, 3 deletions
diff --git a/bazarr/database.py b/bazarr/database.py index 634bcba98..8662010ce 100644 --- a/bazarr/database.py +++ b/bazarr/database.py @@ -7,6 +7,7 @@ import gevent from peewee import * from playhouse.sqliteq import SqliteQueueDatabase from playhouse.shortcuts import model_to_dict +from playhouse.migrate import * from helper import path_mappings from config import settings, get_array_from @@ -16,6 +17,7 @@ database = SqliteQueueDatabase(os.path.join(args.config_dir, 'db', 'bazarr.db'), use_gevent=True, autostart=True, queue_max_size=256) +migrator = SqliteMigrator(database) @atexit.register @@ -284,6 +286,50 @@ def init_db(): tables_created = True +def migrate_db(): + migrate( + migrator.add_column('table_shows', 'year', TextField(null=True)), + migrator.add_column('table_shows', 'alternateTitles', TextField(null=True)), + migrator.add_column('table_shows', 'tags', TextField(default='[]', null=True)), + migrator.add_column('table_shows', 'seriesType', TextField(default='""', null=True)), + migrator.add_column('table_shows', 'imdbId', TextField(default='""', null=True)), + migrator.add_column('table_shows', 'profileId', IntegerField(null=True)), + migrator.add_column('table_episodes', 'format', TextField(null=True)), + migrator.add_column('table_episodes', 'resolution', TextField(null=True)), + migrator.add_column('table_episodes', 'video_codec', TextField(null=True)), + migrator.add_column('table_episodes', 'audio_codec', TextField(null=True)), + migrator.add_column('table_episodes', 'episode_file_id', IntegerField(null=True)), + migrator.add_column('table_episodes', 'audio_language', TextField(null=True)), + migrator.add_column('table_episodes', 'file_size', IntegerField(default=0, null=True)), + migrator.add_column('table_episodes', 'ffprobe_cache', BlobField(null=True)), + migrator.add_column('table_movies', 'sortTitle', TextField(null=True)), + migrator.add_column('table_movies', 'year', TextField(null=True)), + migrator.add_column('table_movies', 'alternativeTitles', TextField(null=True)), + migrator.add_column('table_movies', 'format', TextField(null=True)), + migrator.add_column('table_movies', 'resolution', TextField(null=True)), + migrator.add_column('table_movies', 'video_codec', TextField(null=True)), + migrator.add_column('table_movies', 'audio_codec', TextField(null=True)), + migrator.add_column('table_movies', 'imdbId', TextField(null=True)), + migrator.add_column('table_movies', 'movie_file_id', IntegerField(null=True)), + migrator.add_column('table_movies', 'tags', TextField(default='[]', null=True)), + migrator.add_column('table_movies', 'profileId', IntegerField(null=True)), + migrator.add_column('table_movies', 'file_size', IntegerField(default=0, null=True)), + migrator.add_column('table_movies', 'ffprobe_cache', BlobField(null=True)), + migrator.add_column('table_history', 'video_path', TextField(null=True)), + migrator.add_column('table_history', 'language', TextField(null=True)), + migrator.add_column('table_history', 'provider', TextField(null=True)), + migrator.add_column('table_history', 'score', TextField(null=True)), + migrator.add_column('table_history', 'subs_id', TextField(null=True)), + migrator.add_column('table_history', 'subtitles_path', TextField(null=True)), + migrator.add_column('table_history_movie', 'video_path', TextField(null=True)), + migrator.add_column('table_history_movie', 'language', TextField(null=True)), + migrator.add_column('table_history_movie', 'provider', TextField(null=True)), + migrator.add_column('table_history_movie', 'score', TextField(null=True)), + migrator.add_column('table_history_movie', 'subs_id', TextField(null=True)), + migrator.add_column('table_history_movie', 'subtitles_path', TextField(null=True)) + ) + + class SqliteDictPathMapper: def __init__(self): pass diff --git a/bazarr/init.py b/bazarr/init.py index 1c39b5f16..f3b3a13f2 100644 --- a/bazarr/init.py +++ b/bazarr/init.py @@ -174,7 +174,8 @@ def init_binaries(): return unrar -from database import init_db +from database import init_db, migrate_db init_db() +migrate_db() init_binaries() path_mappings.update() diff --git a/bazarr/logger.py b/bazarr/logger.py index 0ccc58a3d..5dae44d55 100644 --- a/bazarr/logger.py +++ b/bazarr/logger.py @@ -73,7 +73,7 @@ def configure_logging(debug=False): logger.addHandler(fh) if debug: - logging.getLogger("sqlite3worker").setLevel(logging.ERROR) + logging.getLogger("peewee").setLevel(logging.DEBUG) logging.getLogger("apscheduler").setLevel(logging.DEBUG) logging.getLogger("subliminal").setLevel(logging.DEBUG) logging.getLogger("subliminal_patch").setLevel(logging.DEBUG) @@ -91,7 +91,7 @@ def configure_logging(debug=False): logging.debug('Operating system: %s', platform.platform()) logging.debug('Python version: %s', platform.python_version()) else: - logging.getLogger("sqlite3worker").setLevel(logging.CRITICAL) + logging.getLogger("peewee").setLevel(logging.CRITICAL) logging.getLogger("apscheduler").setLevel(logging.WARNING) logging.getLogger("apprise").setLevel(logging.WARNING) logging.getLogger("subliminal").setLevel(logging.CRITICAL) |