# -*- coding: utf-8 -*-

from ppms.migration import SQLPacket, PacketCategory, MinVersionDependency, MaxVersionDependency, VersionType

class FixListboxValuesOPS(SQLPacket):
    """Fix wrong values in object protection DIs of table DT 447 (Listbox Values)
    """

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


    dml_file = 'wi13926_fix_ops_dt447.sql'


    def get_dependencies(self):
        return (MinVersionDependency(version='39.4', version_type=VersionType.CUSTOMIZING),
                MaxVersionDependency(version='39.5.6', version_type=VersionType.CUSTOMIZING))


    def fix(self, runner):
        try:
            # execute sql file, that does the job
            self.apply_dml_file(self.sql_planta_de_ansi, self.dml_file)

            return self.success()
        except Exception as e:
            self.fail(e)
