Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix watched null values. #5132

Merged
merged 11 commits into from
Sep 9, 2018
7 changes: 6 additions & 1 deletion medusa/databases/main_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def check(self):
self.fix_show_nfo_lang()
self.fix_subtitle_reference()
self.clean_null_indexer_mappings()
self.fix_tv_episodes_watched_field()

def clean_null_indexer_mappings(self):
log.debug(u'Checking for null indexer mappings')
Expand Down Expand Up @@ -221,6 +222,10 @@ def fix_subtitles_codes(self):
def fix_show_nfo_lang(self):
self.connection.action("UPDATE tv_shows SET lang = '' WHERE lang = 0 OR lang = '0';")

def fix_tv_episodes_watched_field(self):
"""A mistake was made when we added this field. Migration didn't go very well."""
self.connection.action('UPDATE tv_episodes SET watched = 0 WHERE watched IS NULL;')


# ======================
# = Main DB Migrations =
Expand Down Expand Up @@ -864,7 +869,7 @@ def execute(self):
'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 DEFAULT -1, release_group TEXT, '
'manually_searched NUMERIC, watched NUMERIC);'
'manually_searched NUMERIC, watched NUMERIC DEFAULT 0);'
)

# Re-insert old values, setting the new column 'watched' to the default value 0.
Expand Down