mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-12-26 02:36:10 +00:00
Merge pull request #528 from mcarlton00/database-version
Store a version parameter in the database for migrations
This commit is contained in:
commit
65c7a5c59c
2 changed files with 26 additions and 0 deletions
|
@ -144,3 +144,15 @@ class JellyfinDatabase():
|
||||||
|
|
||||||
def remove_media_by_parent_id(self, *args):
|
def remove_media_by_parent_id(self, *args):
|
||||||
self.cursor.execute(QU.delete_media_by_parent_id, args)
|
self.cursor.execute(QU.delete_media_by_parent_id, args)
|
||||||
|
|
||||||
|
def get_version(self):
|
||||||
|
self.cursor.execute(QU.get_version)
|
||||||
|
|
||||||
|
return self.cursor.fetchone()
|
||||||
|
|
||||||
|
def add_version(self, *args):
|
||||||
|
'''
|
||||||
|
We only ever want one value here, so erase the existing contents first
|
||||||
|
'''
|
||||||
|
self.cursor.execute(QU.delete_version)
|
||||||
|
self.cursor.execute(QU.add_version, args)
|
||||||
|
|
|
@ -26,6 +26,7 @@ from helper import LazyLogger
|
||||||
LOG = LazyLogger(__name__)
|
LOG = LazyLogger(__name__)
|
||||||
LIMIT = int(settings('limitIndex') or 15)
|
LIMIT = int(settings('limitIndex') or 15)
|
||||||
DTHREADS = int(settings('limitThreads') or 3)
|
DTHREADS = int(settings('limitThreads') or 3)
|
||||||
|
TARGET_DB_VERSION = 1
|
||||||
|
|
||||||
##################################################################################################
|
##################################################################################################
|
||||||
|
|
||||||
|
@ -110,6 +111,18 @@ class Library(threading.Thread):
|
||||||
with Database('video'), Database('music'):
|
with Database('video'), Database('music'):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def check_version(self):
|
||||||
|
'''
|
||||||
|
Checks database version and triggers any required data migrations
|
||||||
|
'''
|
||||||
|
with Database('jellyfin') as jellyfindb:
|
||||||
|
db = jellyfin_db.JellyfinDatabase(jellyfindb.cursor)
|
||||||
|
db_version = db.get_version()
|
||||||
|
|
||||||
|
if not db_version:
|
||||||
|
# Make sure we always have a version in the database
|
||||||
|
db.add_version((TARGET_DB_VERSION))
|
||||||
|
|
||||||
@stop
|
@stop
|
||||||
def service(self):
|
def service(self):
|
||||||
|
|
||||||
|
@ -303,6 +316,7 @@ class Library(threading.Thread):
|
||||||
Check for the server plugin.
|
Check for the server plugin.
|
||||||
'''
|
'''
|
||||||
self.test_databases()
|
self.test_databases()
|
||||||
|
self.check_version()
|
||||||
|
|
||||||
Views().get_views()
|
Views().get_views()
|
||||||
Views().get_nodes()
|
Views().get_nodes()
|
||||||
|
|
Loading…
Reference in a new issue