From 5dbfc81bb2f55c8c8ff5f510d7565b8e9c420210 Mon Sep 17 00:00:00 2001 From: echel0n Date: Tue, 22 Apr 2014 10:56:19 -0700 Subject: [PATCH] Fixes other temp tables that may have been left behind from a bad migration of the db --- sickbeard/databases/cache_db.py | 6 ++++++ sickbeard/databases/mainDB.py | 20 ++++++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/sickbeard/databases/cache_db.py b/sickbeard/databases/cache_db.py index cbfb5a3e..0d5cf724 100644 --- a/sickbeard/databases/cache_db.py +++ b/sickbeard/databases/cache_db.py @@ -82,6 +82,9 @@ class ConvertSceneExceptionsToIndexerID(AddXemRefresh): return self.hasColumn("scene_exceptions", "indexer_id") def execute(self): + if self.hasTable("tmp_scene_exceptions"): + self.connection.action("DROP TABLE tmp_scene_exceptions") + self.connection.action("ALTER TABLE scene_exceptions RENAME TO tmp_scene_exceptions") self.connection.action( "CREATE TABLE scene_exceptions (exception_id INTEGER PRIMARY KEY, indexer_id INTEGER KEY, show_name TEXT)") @@ -95,6 +98,9 @@ class ConvertSceneNamesToIndexerID(ConvertSceneExceptionsToIndexerID): return self.hasColumn("scene_names", "indexer_id") def execute(self): + if self.hasTable("tmp_scene_names"): + self.connection.action("DROP TABLE tmp_scene_names") + self.connection.action("ALTER TABLE scene_names RENAME TO tmp_scene_names") self.connection.action("CREATE TABLE scene_names (indexer_id INTEGER, name TEXT)") self.connection.action("INSERT INTO scene_names(indexer_id, name) SELECT tvdb_id, name FROM tmp_scene_names") diff --git a/sickbeard/databases/mainDB.py b/sickbeard/databases/mainDB.py index 9c08012e..b6ac5006 100644 --- a/sickbeard/databases/mainDB.py +++ b/sickbeard/databases/mainDB.py @@ -552,8 +552,9 @@ class ConvertTVShowsToIndexerScheme(AddIndicesToTvEpisodes): logger.log(u"Converting TV Shows table to Indexer Scheme...") - if self.hasTable('tmp_tv_shows'): - logger.log(u"Removing temp tables left behind from previous updates...") + + if self.hasTable("tmp_tv_shows"): + logger.log(u"Removing temp tv show tables left behind from previous updates...") self.connection.action("DROP TABLE tmp_tv_shows") self.connection.action("ALTER TABLE tv_shows RENAME TO tmp_tv_shows") @@ -576,6 +577,11 @@ class ConvertTVEpisodesToIndexerScheme(ConvertTVShowsToIndexerScheme): backupDatabase(23) logger.log(u"Converting TV Episodes table to Indexer Scheme...") + + if self.hasTable("tmp_tv_episodes"): + logger.log(u"Removing temp tv episode tables left behind from previous updates...") + self.connection.action("DROP TABLE tmp_tv_episodes") + self.connection.action("ALTER TABLE tv_episodes RENAME TO tmp_tv_episodes") self.connection.action( "CREATE TABLE tv_episodes (episode_id INTEGER PRIMARY KEY, showid NUMERIC, indexerid NUMERIC, indexer NUMERIC, name TEXT, season NUMERIC, episode NUMERIC, description TEXT, airdate NUMERIC, hasnfo NUMERIC, hastbn NUMERIC, status NUMERIC, location TEXT, file_size NUMERIC, release_name TEXT, subtitles TEXT, subtitles_searchcount NUMERIC, subtitles_lastsearch TIMESTAMP, is_proper NUMERIC)") @@ -595,6 +601,11 @@ class ConvertIMDBInfoToIndexerScheme(ConvertTVEpisodesToIndexerScheme): backupDatabase(24) logger.log(u"Converting IMDB Info table to Indexer Scheme...") + + if self.hasTable("tmp_imdb_info"): + logger.log(u"Removing temp imdb info tables left behind from previous updates...") + self.connection.action("DROP TABLE tmp_imdb_info") + self.connection.action("ALTER TABLE imdb_info RENAME TO tmp_imdb_info") self.connection.action( "CREATE TABLE imdb_info (indexer_id INTEGER PRIMARY KEY, imdb_id TEXT, title TEXT, year NUMERIC, akas TEXT, runtimes NUMERIC, genres TEXT, countries TEXT, country_codes TEXT, certificates TEXT, rating TEXT, votes INTEGER, last_update NUMERIC)") @@ -613,6 +624,11 @@ class ConvertInfoToIndexerScheme(ConvertIMDBInfoToIndexerScheme): backupDatabase(25) logger.log(u"Converting Info table to Indexer Scheme...") + + if self.hasTable("tmp_info"): + logger.log(u"Removing temp info tables left behind from previous updates...") + self.connection.action("DROP TABLE tmp_info") + self.connection.action("ALTER TABLE info RENAME TO tmp_info") self.connection.action( "CREATE TABLE info (last_backlog NUMERIC, last_indexer NUMERIC, last_proper_search NUMERIC)")