def execute(self): db.backup_database('cache.db', self.checkDBVersion()) if self.hasTable('provider_cache'): self.connection.action('DROP TABLE provider_cache') self.connection.action( 'CREATE TABLE provider_cache (provider TEXT, name TEXT, season NUMERIC, episodes TEXT, ' 'indexerid NUMERIC, url TEXT UNIQUE, time NUMERIC, quality TEXT, release_group TEXT, ' 'version NUMERIC)') if not self.hasTable('network_conversions'): self.connection.action( 'CREATE TABLE network_conversions ' + '(tvdb_network TEXT PRIMARY KEY, tvrage_network TEXT, tvrage_country TEXT)' ) self.connection.action( 'CREATE INDEX tvrage_idx ' + 'on network_conversions (tvrage_network, tvrage_country)') keep_tables = set([ 'lastUpdate', 'lastSearch', 'db_version', 'network_timezones', 'network_conversions', 'provider_cache' ]) current_tables = set(self.listTables()) remove_tables = list(current_tables - keep_tables) for table in remove_tables: self.connection.action('DROP TABLE [%s]' % table) self.incDBVersion()
def execute(self): db.backup_database('sickbeard.db', self.checkDBVersion()) logger.log(u'Bumping database version to new SickGear standards') self.setDBVersion(20000) return self.checkDBVersion()
def execute(self): db.backup_database('sickbeard.db', self.checkDBVersion()) cl = [] logger.log(u'Converting Indexer to Integer ...', logger.MESSAGE) cl.append([ 'UPDATE tv_shows SET indexer = ? WHERE LOWER(indexer) = ?', ['1', 'tvdb'] ]) cl.append([ 'UPDATE tv_shows SET indexer = ? WHERE LOWER(indexer) = ?', ['2', 'tvrage'] ]) cl.append([ 'UPDATE tv_episodes SET indexer = ? WHERE LOWER(indexer) = ?', ['1', 'tvdb'] ]) cl.append([ 'UPDATE tv_episodes SET indexer = ? WHERE LOWER(indexer) = ?', ['2', 'tvrage'] ]) cl.append([ 'UPDATE scene_numbering SET indexer = ? WHERE LOWER(indexer) = ?', ['1', 'tvdb'] ]) cl.append([ 'UPDATE scene_numbering SET indexer = ? WHERE LOWER(indexer) = ?', ['2', 'tvrage'] ]) self.connection.mass_action(cl) self.incDBVersion() return self.checkDBVersion()
def execute(self): db.backup_database('sickbeard.db', self.checkDBVersion()) 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)') self.connection.action( 'INSERT INTO tv_episodes(episode_id, showid, indexerid, name, season, episode, description, airdate, hasnfo, hastbn, status, location, file_size, release_name, subtitles, subtitles_searchcount, subtitles_lastsearch, is_proper) SELECT episode_id, showid, tvdbid, name, season, episode, description, airdate, hasnfo, hastbn, status, location, file_size, release_name, subtitles, subtitles_searchcount, subtitles_lastsearch, is_proper FROM tmp_tv_episodes') self.connection.action('DROP TABLE tmp_tv_episodes') self.connection.action('CREATE INDEX idx_tv_episodes_showid_airdate ON tv_episodes(showid,airdate);') self.connection.action('CREATE INDEX idx_showid ON tv_episodes (showid);') self.connection.action('CREATE INDEX idx_status ON tv_episodes (status,season,episode,airdate)') self.connection.action('CREATE INDEX idx_sta_epi_air ON tv_episodes (status,episode, airdate)') self.connection.action('CREATE INDEX idx_sta_epi_sta_air ON tv_episodes (season,episode, status, airdate)') self.connection.action('UPDATE tv_episodes SET indexer = 1') self.incDBVersion() return self.checkDBVersion()
def execute(self): db.backup_database('sickbeard.db', self.checkDBVersion()) if not self.hasColumn('tv_shows', 'sports'): logger.log(u'Adding column sports to tv_shows') self.addColumn('tv_shows', 'sports', 'NUMERIC', '0') if self.hasColumn('tv_shows', 'air_by_date') and self.hasColumn( 'tv_shows', 'sports'): # update sports column logger.log( u'[4/4] Updating tv_shows to reflect the correct sports value...', logger.MESSAGE) cl = [] history_quality = self.connection.select( 'SELECT * FROM tv_shows WHERE LOWER(classification) = "sports" AND air_by_date = 1 AND sports = 0' ) for cur_entry in history_quality: cl.append([ 'UPDATE tv_shows SET sports = ? WHERE show_id = ?', [cur_entry['air_by_date'], cur_entry['show_id']] ]) cl.append([ 'UPDATE tv_shows SET air_by_date = 0 WHERE show_id = ?', [cur_entry['show_id']] ]) self.connection.mass_action(cl) self.incDBVersion() return self.checkDBVersion()
def execute(self): db.backup_database('sickbeard.db', self.checkDBVersion()) # rename the column self.connection.action('ALTER TABLE tv_shows RENAME TO tmp_tv_shows') self.connection.action( 'CREATE TABLE tv_shows (show_id INTEGER PRIMARY KEY, location TEXT, show_name TEXT, tvdb_id NUMERIC, network TEXT, genre TEXT, runtime NUMERIC, quality NUMERIC, airs TEXT, status TEXT, flatten_folders NUMERIC, paused NUMERIC, startyear NUMERIC, tvr_id NUMERIC, tvr_name TEXT, air_by_date NUMERIC, lang TEXT)' ) sql = 'INSERT INTO tv_shows(show_id, location, show_name, tvdb_id, network, genre, runtime, quality, airs, status, flatten_folders, paused, startyear, tvr_id, tvr_name, air_by_date, lang) SELECT show_id, location, show_name, tvdb_id, network, genre, runtime, quality, airs, status, seasonfolders, paused, startyear, tvr_id, tvr_name, air_by_date, lang FROM tmp_tv_shows' self.connection.action(sql) # flip the values to be opposite of what they were before self.connection.action( 'UPDATE tv_shows SET flatten_folders = 2 WHERE flatten_folders = 1' ) self.connection.action( 'UPDATE tv_shows SET flatten_folders = 1 WHERE flatten_folders = 0' ) self.connection.action( 'UPDATE tv_shows SET flatten_folders = 0 WHERE flatten_folders = 2' ) self.connection.action('DROP TABLE tmp_tv_shows') self.incDBVersion() return self.checkDBVersion()
def execute(self): db.backup_database('sickbeard.db', self.checkDBVersion()) logger.log(u'Bumping database version') self.setDBVersion(10001) return self.checkDBVersion()
def execute(self): db.backup_database('sickbeard.db', self.checkDBVersion()) logger.log(u'Migrate SickBeard DB v%s into v15' % str(self.checkDBVersion()).replace('58', '')) self.setDBVersion(15) return self.checkDBVersion()
def execute(self): db.backup_database('sickbeard.db', self.checkDBVersion()) logger.log(u'Converting TV Shows table to Indexer Scheme...') 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') self.connection.action( 'CREATE TABLE tv_shows (show_id INTEGER PRIMARY KEY, indexer_id NUMERIC, indexer NUMERIC, show_name TEXT, location TEXT, network TEXT, genre TEXT, classification TEXT, runtime NUMERIC, quality NUMERIC, airs TEXT, status TEXT, flatten_folders NUMERIC, paused NUMERIC, startyear NUMERIC, air_by_date NUMERIC, lang TEXT, subtitles NUMERIC, notify_list TEXT, imdb_id TEXT, last_update_indexer NUMERIC, dvdorder NUMERIC)' ) self.connection.action( 'INSERT INTO tv_shows(show_id, indexer_id, show_name, location, network, genre, runtime, quality, airs, status, flatten_folders, paused, startyear, air_by_date, lang, subtitles, notify_list, imdb_id, last_update_indexer, dvdorder) SELECT show_id, tvdb_id, show_name, location, network, genre, runtime, quality, airs, status, flatten_folders, paused, startyear, air_by_date, lang, subtitles, notify_list, imdb_id, last_update_tvdb, dvdorder FROM tmp_tv_shows' ) self.connection.action('DROP TABLE tmp_tv_shows') self.connection.action( 'CREATE UNIQUE INDEX idx_indexer_id ON tv_shows (indexer_id);') self.connection.action( 'UPDATE tv_shows SET classification = "Scripted"') self.connection.action('UPDATE tv_shows SET indexer = 1') self.incDBVersion() return self.checkDBVersion()
def execute(self): db.backup_database('sickbeard.db', self.checkDBVersion()) if not self.hasTable('tv_shows') and not self.hasTable('db_version'): queries = [ 'CREATE TABLE db_version (db_version INTEGER);', 'CREATE TABLE history (' 'action NUMERIC, date NUMERIC, showid NUMERIC, season NUMERIC, episode NUMERIC,' ' quality NUMERIC, resource TEXT, provider TEXT);', '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);', 'CREATE TABLE info (last_backlog NUMERIC, last_indexer NUMERIC, last_proper_search NUMERIC);', '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));', 'CREATE TABLE tv_shows (show_id INTEGER PRIMARY KEY, indexer_id NUMERIC, indexer NUMERIC,' ' show_name TEXT, location TEXT, network TEXT, genre TEXT, classification TEXT, runtime NUMERIC,' ' quality NUMERIC, airs TEXT, status TEXT, flatten_folders NUMERIC, paused NUMERIC,' ' startyear NUMERIC, air_by_date NUMERIC, lang TEXT, subtitles NUMERIC, notify_list TEXT,' ' imdb_id TEXT, last_update_indexer NUMERIC, dvdorder NUMERIC, archive_firstmatch NUMERIC,' ' rls_require_words TEXT, rls_ignore_words TEXT, sports NUMERIC);', '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, scene_season NUMERIC, scene_episode NUMERIC);', 'CREATE UNIQUE INDEX idx_indexer_id ON tv_shows (indexer_id);', 'CREATE INDEX idx_showid ON tv_episodes (showid);', 'CREATE INDEX idx_sta_epi_air ON tv_episodes (status,episode, airdate);', 'CREATE INDEX idx_sta_epi_sta_air ON tv_episodes (season,episode, status, airdate);', 'CREATE INDEX idx_status ON tv_episodes (status,season,episode,airdate);', 'CREATE INDEX idx_tv_episodes_showid_airdate ON tv_episodes(showid,airdate);', 'INSERT INTO db_version (db_version) VALUES (31);' ] for query in queries: self.connection.action(query) else: cur_db_version = self.checkDBVersion() if cur_db_version < MIN_DB_VERSION: logger.log_error_and_exit( u'Your database version (' + str(cur_db_version) + ') is too old to migrate from what this version of SickGear supports (' + str(MIN_DB_VERSION) + ').' + '\n' + 'Upgrade using a previous version (tag) build 496 to build 501 of SickGear first or' ' remove database file to begin fresh.') if cur_db_version > MAX_DB_VERSION: logger.log_error_and_exit( u'Your database version (' + str(cur_db_version) + ') has been incremented past what this version of SickGear supports (' + str(MAX_DB_VERSION) + ').' + '\n' + 'If you have used other forks of SickGear,' ' your database may be unusable due to their modifications.' ) return self.checkDBVersion()
def execute(self): db.backup_database('sickbeard.db', self.checkDBVersion()) logger.log(u'Adding tag to tv_shows') self.addColumn('tv_shows', 'tag', 'TEXT', 'Show List') self.setDBVersion(20003) return self.checkDBVersion()
def execute(self): db.backup_database('sickbeard.db', self.checkDBVersion()) logger.log(u'Adding column overview to tv_shows') self.addColumn('tv_shows', 'overview', 'TEXT', '') self.setDBVersion(20002) return self.checkDBVersion()
def execute(self): db.backup_database('sickbeard.db', self.checkDBVersion()) logger.log(u'Dropping column default_ep_status from tv_shows') self.dropColumn('tv_shows', 'default_ep_status') self.setDBVersion(10000) return self.checkDBVersion()
def execute(self): db.backup_database('sickbeard.db', self.checkDBVersion()) logger.log(u'Adding column scene to tv_shows') self.addColumn('tv_shows', 'scene', 'NUMERIC', '0') self.incDBVersion() return self.checkDBVersion()
def execute(self): db.backup_database('sickbeard.db', self.checkDBVersion()) logger.log(u'Dropping redundant column') self.dropColumn('db_version', 'db_minor_version') self.setDBVersion(10001) return self.checkDBVersion()
def execute(self): db.backup_database('sickbeard.db', self.checkDBVersion()) logger.log(u'Adding column scene_absolute_number to tv_episodes') self.addColumn('tv_episodes', 'scene_absolute_number', 'NUMERIC', '0') self.incDBVersion() return self.checkDBVersion()
def execute(self): db.backup_database('sickbeard.db', self.checkDBVersion()) logger.log(u'Creating table xem_refresh') self.connection.action( 'CREATE TABLE xem_refresh (indexer TEXT, indexer_id INTEGER PRIMARY KEY, last_refreshed INTEGER)') self.incDBVersion() return self.checkDBVersion()
def execute(self): db.backup_database('sickbeard.db', self.checkDBVersion()) if self.hasColumn('tv_shows', 'sub_use_sr_metadata'): logger.log(u'Dropping redundant column metadata sub') self.dropColumn('tv_shows', 'sub_use_sr_metadata') self.setDBVersion(10002) return self.checkDBVersion()
def execute(self): db.backup_database('sickbeard.db', self.checkDBVersion()) if not self.hasColumn('tv_shows', 'last_update_tvdb'): logger.log(u'Adding column last_update_tvdb to tv_shows') self.addColumn('tv_shows', 'last_update_tvdb', default=1) self.incDBVersion() return self.checkDBVersion()
def execute(self): db.backup_database('sickbeard.db', self.checkDBVersion()) if not self.hasColumn('tv_shows', 'dvdorder'): logger.log(u'Adding column dvdorder to tv_shows') self.addColumn('tv_shows', 'dvdorder', 'NUMERIC', '0') self.incDBVersion() return self.checkDBVersion()
def execute(self): db.backup_database('sickbeard.db', self.checkDBVersion()) logger.log(u'Adding columns scene_season and scene_episode to tvepisodes') self.addColumn('tv_episodes', 'scene_season', 'NUMERIC', 'NULL') self.addColumn('tv_episodes', 'scene_episode', 'NUMERIC', 'NULL') self.incDBVersion() return self.checkDBVersion()
def execute(self): db.backup_database('sickbeard.db', self.checkDBVersion()) if not self.hasColumn('tv_shows', 'archive_firstmatch'): logger.log(u'Adding column archive_firstmatch to tv_shows') self.addColumn('tv_shows', 'archive_firstmatch', 'NUMERIC', '0') self.incDBVersion() return self.checkDBVersion()
def execute(self): db.backup_database('sickbeard.db', self.checkDBVersion()) logger.log(u'Bumping database version to force a backup before new database code') self.connection.action('VACUUM') logger.log(u'Performed a vacuum on the database', logger.DEBUG) self.setDBVersion(20001) return self.checkDBVersion()
def execute(self): db.backup_database('sickbeard.db', self.checkDBVersion()) logger.log(u'Creating table xem_refresh') self.connection.action( 'CREATE TABLE xem_refresh (indexer TEXT, indexer_id INTEGER PRIMARY KEY, last_refreshed INTEGER)' ) self.incDBVersion() return self.checkDBVersion()
def execute(self): db.backup_database('sickbeard.db', self.checkDBVersion()) logger.log( u'Adding columns scene_season and scene_episode to tvepisodes') self.addColumn('tv_episodes', 'scene_season', 'NUMERIC', 'NULL') self.addColumn('tv_episodes', 'scene_episode', 'NUMERIC', 'NULL') self.incDBVersion() return self.checkDBVersion()
def execute(self): db.backup_database('sickbeard.db', self.checkDBVersion()) cl = [] cl.append(['CREATE TABLE blacklist (show_id INTEGER, range TEXT, keyword TEXT)']) cl.append(['CREATE TABLE whitelist (show_id INTEGER, range TEXT, keyword TEXT)']) logger.log(u'Creating table blacklist whitelist') self.connection.mass_action(cl) self.incDBVersion() return self.checkDBVersion()
def execute(self): db.backup_database('sickbeard.db', self.checkDBVersion()) if not self.hasColumn('tv_shows', 'subtitles'): logger.log(u'Adding subtitles to tv_shows and tv_episodes') self.addColumn('tv_shows', 'subtitles') self.addColumn('tv_episodes', 'subtitles', 'TEXT', '') self.addColumn('tv_episodes', 'subtitles_searchcount') self.addColumn('tv_episodes', 'subtitles_lastsearch', 'TIMESTAMP', str(datetime.datetime.min)) self.incDBVersion() return self.checkDBVersion()
def execute(self): db.backup_database('sickbeard.db', self.checkDBVersion()) logger.log(u'Adding columns release_group and version to tv_episodes') self.addColumn('tv_episodes', 'release_group', 'TEXT', '') self.addColumn('tv_episodes', 'version', 'NUMERIC', '-1') logger.log(u'Adding column version to history') self.addColumn('history', 'version', 'NUMERIC', '-1') self.incDBVersion() return self.checkDBVersion()
def execute(self): db.backup_database('sickbeard.db', self.checkDBVersion()) if self.hasTable('scene_numbering'): self.connection.action('DROP TABLE scene_numbering') logger.log(u'Upgrading table scene_numbering ...', logger.MESSAGE) 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() return self.checkDBVersion()
def execute(self): db.backup_database('sickbeard.db', self.checkDBVersion()) if self.hasTable('indexer_mapping'): self.connection.action('DROP TABLE indexer_mapping') logger.log(u'Adding table indexer_mapping') self.connection.action( 'CREATE TABLE indexer_mapping (indexer_id INTEGER, indexer NUMERIC, mindexer_id INTEGER, mindexer NUMERIC, PRIMARY KEY (indexer_id, indexer))') self.incDBVersion() return self.checkDBVersion()
def execute(self): db.backup_database('sickbeard.db', self.checkDBVersion()) logger.log( u'Bumping database version to force a backup before new database code' ) self.connection.action('VACUUM') logger.log(u'Performed a vacuum on the database', logger.DEBUG) self.setDBVersion(20001) return self.checkDBVersion()
def execute(self): db.backup_database('sickbeard.db', self.checkDBVersion()) if self.hasTable('scene_numbering'): self.connection.action('DROP TABLE scene_numbering') logger.log(u'Upgrading table scene_numbering ...', logger.MESSAGE) 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() return self.checkDBVersion()
def execute(self): db.backup_database('sickbeard.db', self.checkDBVersion()) logger.log(u'Creating IMDb table imdb_info') self.connection.action( 'CREATE TABLE imdb_info (tvdb_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)') if not self.hasColumn('tv_shows', 'imdb_id'): logger.log(u'Adding IMDb column imdb_id to tv_shows') self.addColumn('tv_shows', 'imdb_id') self.incDBVersion() return self.checkDBVersion()
def execute(self): db.backup_database('sickbeard.db', self.checkDBVersion()) if self.hasTable('indexer_mapping'): self.connection.action('DROP TABLE indexer_mapping') logger.log(u'Adding table indexer_mapping') self.connection.action( 'CREATE TABLE indexer_mapping (indexer_id INTEGER, indexer NUMERIC, mindexer_id INTEGER, mindexer NUMERIC, PRIMARY KEY (indexer_id, indexer))' ) self.incDBVersion() return self.checkDBVersion()
def execute(self): db.backup_database('sickbeard.db', self.checkDBVersion()) logger.log(u'Checking for duplicate shows before adding unique index.') MainSanityCheck(self.connection).fix_duplicate_shows('tvdb_id') logger.log(u'Adding index on tvdb_id (tv_shows) and showid (tv_episodes) to speed up searches/queries.') if not self.hasTable('idx_showid'): self.connection.action('CREATE INDEX idx_showid ON tv_episodes (showid);') if not self.hasTable('idx_tvdb_id'): self.connection.action('CREATE UNIQUE INDEX idx_tvdb_id ON tv_shows (tvdb_id);') self.incDBVersion() return self.checkDBVersion()
def execute(self): db.backup_database('sickbeard.db', self.checkDBVersion()) logger.log(u'Creating IMDb table imdb_info') self.connection.action( 'CREATE TABLE imdb_info (tvdb_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)' ) if not self.hasColumn('tv_shows', 'imdb_id'): logger.log(u'Adding IMDb column imdb_id to tv_shows') self.addColumn('tv_shows', 'imdb_id') self.incDBVersion() return self.checkDBVersion()
def execute(self): db.backup_database('sickbeard.db', self.checkDBVersion()) if not self.hasColumn('tv_shows', 'imdb_id')\ and self.hasColumn('tv_shows', 'rls_require_words')\ and self.hasColumn('tv_shows', 'rls_ignore_words'): self.setDBVersion(5816) return self.checkDBVersion() if not self.hasColumn('tv_episodes', 'is_proper'): logger.log(u'Adding column is_proper to tv_episodes') self.addColumn('tv_episodes', 'is_proper') self.incDBVersion() return self.checkDBVersion()
def execute(self): db.backup_database('sickbeard.db', self.checkDBVersion()) cl = [] cl.append([ 'CREATE TABLE blacklist (show_id INTEGER, range TEXT, keyword TEXT)' ]) cl.append([ 'CREATE TABLE whitelist (show_id INTEGER, range TEXT, keyword TEXT)' ]) logger.log(u'Creating table blacklist whitelist') self.connection.mass_action(cl) self.incDBVersion() return self.checkDBVersion()
def execute(self): db.backup_database('sickbeard.db', self.checkDBVersion()) if not self.hasTable('tv_shows') and not self.hasTable('db_version'): queries = [ # original sick beard tables 'CREATE TABLE db_version (db_version INTEGER);', 'CREATE TABLE history (action NUMERIC, date NUMERIC, showid NUMERIC, season NUMERIC, episode NUMERIC, quality NUMERIC, resource TEXT, provider TEXT, version NUMERIC)', 'CREATE TABLE info (last_backlog NUMERIC, last_indexer NUMERIC, last_proper_search NUMERIC)', '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, scene_season NUMERIC, scene_episode NUMERIC, absolute_number NUMERIC, scene_absolute_number NUMERIC, version NUMERIC, release_group TEXT, trakt_watched NUMERIC)', 'CREATE TABLE tv_shows (show_id INTEGER PRIMARY KEY, indexer_id NUMERIC, indexer NUMERIC, show_name TEXT, location TEXT, network TEXT, genre TEXT, classification TEXT, runtime NUMERIC, quality NUMERIC, airs TEXT, status TEXT, flatten_folders NUMERIC, paused NUMERIC, startyear NUMERIC, air_by_date NUMERIC, lang TEXT, subtitles NUMERIC, notify_list TEXT, imdb_id TEXT, last_update_indexer NUMERIC, dvdorder NUMERIC, archive_firstmatch NUMERIC, rls_require_words TEXT, rls_ignore_words TEXT, sports NUMERIC, anime NUMERIC, scene NUMERIC, overview TEXT, tag TEXT)', 'CREATE INDEX idx_showid ON tv_episodes (showid)', 'CREATE INDEX idx_tv_episodes_showid_airdate ON tv_episodes (showid,airdate)', 'CREATE TABLE blacklist (show_id INTEGER, range TEXT, keyword TEXT)', 'CREATE TABLE indexer_mapping (indexer_id INTEGER, indexer NUMERIC, mindexer_id INTEGER, mindexer NUMERIC, PRIMARY KEY (indexer_id, indexer))', '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)', 'CREATE TABLE scene_numbering (indexer TEXT, indexer_id INTEGER, season INTEGER, episode INTEGER, scene_season INTEGER, scene_episode INTEGER, absolute_number NUMERIC, scene_absolute_number NUMERIC, PRIMARY KEY (indexer_id, season, episode))', 'CREATE TABLE whitelist (show_id INTEGER, range TEXT, keyword TEXT)', 'CREATE TABLE xem_refresh (indexer TEXT, indexer_id INTEGER PRIMARY KEY, last_refreshed INTEGER)', 'CREATE UNIQUE INDEX idx_indexer_id ON tv_shows (indexer_id)', 'CREATE INDEX idx_sta_epi_air ON tv_episodes (status,episode, airdate)', 'CREATE INDEX idx_sta_epi_sta_air ON tv_episodes (season,episode, status, airdate)', 'CREATE INDEX idx_status ON tv_episodes (status,season,episode,airdate)', 'INSERT INTO db_version (db_version) VALUES (20003)' ] for query in queries: self.connection.action(query) else: cur_db_version = self.checkDBVersion() if cur_db_version < MIN_DB_VERSION: logger.log_error_and_exit(u'Your database version (' + str(cur_db_version) + ') is too old to migrate from what this version of SickGear supports (' + str(MIN_DB_VERSION) + ').' + "\n" + 'Upgrade using a previous version (tag) build 496 to build 501 of SickGear first or remove database file to begin fresh.' ) if cur_db_version > MAX_DB_VERSION: logger.log_error_and_exit(u'Your database version (' + str(cur_db_version) + ') has been incremented past what this version of SickGear supports (' + str(MAX_DB_VERSION) + ').' + "\n" + 'If you have used other forks of SickGear, your database may be unusable due to their modifications.' ) return self.checkDBVersion()
def execute(self): db.backup_database('sickbeard.db', self.checkDBVersion()) if not self.hasColumn('tv_episodes', 'is_proper')\ and self.hasColumn('tv_shows', 'rls_require_words')\ and self.hasColumn('tv_shows', 'rls_ignore_words')\ and self.hasColumn('tv_shows', 'skip_notices'): self.setDBVersion(5817) return self.checkDBVersion() if not self.hasColumn('tv_shows', 'notify_list'): logger.log(u'Adding column notify_list to tv_shows') self.addColumn('tv_shows', 'notify_list', 'TEXT', None) self.incDBVersion() return self.checkDBVersion()
def execute(self): db.backup_database('sickbeard.db', self.checkDBVersion()) cl = [] logger.log(u'Converting Indexer to Integer ...', logger.MESSAGE) cl.append(['UPDATE tv_shows SET indexer = ? WHERE LOWER(indexer) = ?', ['1', 'tvdb']]) cl.append(['UPDATE tv_shows SET indexer = ? WHERE LOWER(indexer) = ?', ['2', 'tvrage']]) cl.append(['UPDATE tv_episodes SET indexer = ? WHERE LOWER(indexer) = ?', ['1', 'tvdb']]) cl.append(['UPDATE tv_episodes SET indexer = ? WHERE LOWER(indexer) = ?', ['2', 'tvrage']]) cl.append(['UPDATE scene_numbering SET indexer = ? WHERE LOWER(indexer) = ?', ['1', 'tvdb']]) cl.append(['UPDATE scene_numbering SET indexer = ? WHERE LOWER(indexer) = ?', ['2', 'tvrage']]) self.connection.mass_action(cl) self.incDBVersion() return self.checkDBVersion()
def execute(self): db.backup_database('sickbeard.db', self.checkDBVersion()) if not self.hasColumn('tv_shows', 'notify_list')\ and self.hasColumn('tv_shows', 'rls_require_words')\ and self.hasColumn('tv_shows', 'rls_ignore_words')\ and self.hasColumn('tv_shows', 'skip_notices')\ and self.hasColumn('history', 'source'): self.setDBVersion(5818) return self.checkDBVersion() if not self.hasColumn('info', 'last_proper_search'): logger.log(u'Adding column last_proper_search to info') self.addColumn('info', 'last_proper_search', default=1) self.incDBVersion() return self.checkDBVersion()
def execute(self): if self.hasColumn('tv_shows', 'rls_require_words') and self.hasColumn('tv_shows', 'rls_ignore_words'): self.incDBVersion() return self.checkDBVersion() db.backup_database('sickbeard.db', self.checkDBVersion()) if not self.hasColumn('tv_shows', 'rls_require_words'): logger.log(u'Adding column rls_require_words to tv_shows') self.addColumn('tv_shows', 'rls_require_words', 'TEXT', '') if not self.hasColumn('tv_shows', 'rls_ignore_words'): logger.log(u'Adding column rls_ignore_words to tv_shows') self.addColumn('tv_shows', 'rls_ignore_words', 'TEXT', '') self.incDBVersion() return self.checkDBVersion()
def execute(self): if self.hasColumn('tv_shows', 'rls_require_words') and self.hasColumn( 'tv_shows', 'rls_ignore_words'): self.incDBVersion() return self.checkDBVersion() db.backup_database('sickbeard.db', self.checkDBVersion()) if not self.hasColumn('tv_shows', 'rls_require_words'): logger.log(u'Adding column rls_require_words to tv_shows') self.addColumn('tv_shows', 'rls_require_words', 'TEXT', '') if not self.hasColumn('tv_shows', 'rls_ignore_words'): logger.log(u'Adding column rls_ignore_words to tv_shows') self.addColumn('tv_shows', 'rls_ignore_words', 'TEXT', '') self.incDBVersion() return self.checkDBVersion()