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

from ppms import ppms
from ppms.migration.packet import *
from ppms.migration import MaxVersionDependency, VersionType

class MSSQLHelperFunctions(SQLPacket):
    """Adds procedures to alter or drop specific columns (while dropping all of their constraints) for MSSQL"""

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

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

    def fix(self, runner):
        if (ppms.db_get_dbms_name() == "000004"): # only needed (and only exists) in MSSQL
            sql_file = "wi14269_helper_functions.sql"
            self.apply_fix_ddl_file(self.sql_planta_de_dbms, sql_file, split=True, separator='SEPARATOR')

        return self.success()