Simplifies movie version migration logic

Consolidates migration logic to handle versions >= 131,
eliminating redundant checks for version ranges.
Clarifies version assignment for Omega and Piers migrations,
ensuring database migrations align with Kodi's automatic behaviors.

Improves code maintainability and reduces duplication.
This commit is contained in:
Jeroen De Meerleer 2025-09-10 17:01:12 +02:00
commit bccb376d21

View file

@ -142,44 +142,31 @@ class Movies(Kodi):
# Will run every time Kodi starts, but will be fast enough on
# subsequent runs to not be a meaningful delay
if 131 <= version_id < 134:
if version_id >= 131:
changes = self.omega_migration()
if version_id >= 134:
changes = self.piers_migration()
return changes
def omega_migration(self):
"""
Adds a video version for all existing movies
For Omega: video_version_id = 0
For Piers: video_version_id = 1
Migration from Nexus to Omega adds video version with id 0
Migration from Nexus to Peirs adds video version with id 1
Migration from Omega to Piers this does nothing and is handled by kodi itself
"""
LOG.info("Starting migration for Omega database changes")
# Tracks if this migration made any changes
changes = False
self.cursor.execute(QU.get_missing_versions)
# Sets all existing movies without a version to standard version
for entry in self.cursor.fetchall():
self.add_videoversion(entry[0], entry[1], "movie", "0", 40400)
changes = True
LOG.info("Omega database migration is complete")
return changes
def piers_migration(self):
"""
Adds a video version for all existing movies
"""
LOG.info("Starting migration for Piers database changes")
# Tracks if this migration made any changes
changes = False
self.cursor.execute(QU.get_missing_versions)
# Sets all existing movies without a version to standard version
for entry in self.cursor.fetchall():
self.add_videoversion(entry[0], entry[1], "movie", 40400, 40400)
changes = True
LOG.info("Piers database migration is complete")
LOG.info("Omega database migration is complete")
return changes