diff --git a/sickbeard/databases/cache_db.py b/sickbeard/databases/cache_db.py index 46ccfebc..a9ac367f 100644 --- a/sickbeard/databases/cache_db.py +++ b/sickbeard/databases/cache_db.py @@ -103,3 +103,11 @@ class ConvertSceneNamesToIndexerID(ConvertSceneExceptionsToIndexerID): self.connection.action("INSERT INTO scene_names(indexer_id, name) SELECT tvdb_id, name FROM tmp_scene_names") self.connection.action("DROP TABLE tmp_scene_names") +class ConvertIndexerToInteger(ConvertSceneNamesToIndexerID): + def execute(self): + ql = [] + ql.append(["UPDATE xem_numbering SET indexer = ? WHERE LOWER(indexer) = ?", ["1", "tvdb"]]) + ql.append(["UPDATE xem_numbering SET indexer = ? WHERE LOWER(indexer) = ?", ["2", "tvrage"]]) + ql.append(["UPDATE xem_refresh SET indexer = ? WHERE LOWER(indexer) = ?", ["1", "tvdb"]]) + ql.append(["UPDATE xem_refresh SET indexer = ? WHERE LOWER(indexer) = ?", ["2", "tvrage"]]) + self.connection.mass_action(ql) diff --git a/sickbeard/databases/mainDB.py b/sickbeard/databases/mainDB.py index ea4f20f5..24d7265b 100644 --- a/sickbeard/databases/mainDB.py +++ b/sickbeard/databases/mainDB.py @@ -643,4 +643,22 @@ class AddSceneNumbering(AddArchiveFirstMatchOption): self.connection.action( "CREATE TABLE scene_numbering (indexer TEXT, indexer_id INTEGER, season INTEGER, episode INTEGER, scene_season INTEGER, scene_episode INTEGER, PRIMARY KEY (indexer_id, season, episode))") + self.incDBVersion() + + +class ConvertIndexerToInteger(AddSceneNumbering): + def test(self): + return self.checkDBVersion() >= 28 + + def execute(self): + backupDatabase(28) + + ql = [] + logger.log(u"Converting Indexer to Integer ...", logger.MESSAGE) + ql.append(["UPDATE tv_shows SET indexer = ? WHERE LOWER(indexer) = ?", ["1", "tvdb"]]) + ql.append(["UPDATE tv_shows SET indexer = ? WHERE LOWER(indexer) = ?", ["2", "tvrage"]]) + ql.append(["UPDATE tv_episodes SET indexer = ? WHERE LOWER(indexer) = ?", ["1", "tvdb"]]) + ql.append(["UPDATE tv_episodes SET indexer = ? WHERE LOWER(indexer) = ?", ["2", "tvrage"]]) + self.connection.mass_action(ql) + self.incDBVersion() \ No newline at end of file