# -*- coding: utf-8 -*-
from ppms.migration.packet import *

class FixPreviewFields(SQLPacket):
    '''Fix an assertion occuring with preview DIs (color, format, symbol).

    Fixes some DIs having different DB-/DF-/PPMS-types than their sub-DIs which
    leads to an assertion.
    '''

    wi_number = 5888
    version = 1
    done_after_success = True
    run_on_startup = True
    category = PacketCategory.CATEGORY_MANDATORY

    SQL = """update dt412
               set di000244 = 'ALG', di003141 = 'ALG', di000253 = 'X'
               where di000238 in ('002076', '002089', '041598')"""

    def fix(self, runner):
        if self.modify_and_log(self.SQL):
            return self.success()
        return self.fail()
