# -*- coding: utf-8 -*-
from ppms.migration import SQLPacket, PacketCategory, MaxVersionDependency
from ppms.constants import DBMS_MSSQL


class FixDT430DT472(SQLPacket):
    """Fix the length of DI "POS" in V_DT430_DT472 in MSSQL"""
    done_after_success = True
    run_on_startup = True
    category = PacketCategory.CATEGORY_MANDATORY
    wi_number = 22183

    sql_script = 'WI22183_fix_V_DT430_DT472.sql'

    def fix(self, packet_runner):
        if self.DBMS == DBMS_MSSQL:
            self.apply_dml_file(self.sql_planta_de_dbms, self.sql_script)
        else:
            self.log("Only needed in MSSQL")

        return self.success()
