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


class ChangeSAPPSPElementCalculation(SQLPacket):
    """Adds and removes real columns in the DB to match the new SAP PSP calculation."""
    done_after_success = True
    run_on_startup = True
    category = PacketCategory.CATEGORY_MANDATORY
    wi_number = 20229

    sql_script = 'WI20229_change_psp_calculation.sql'

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

    def fix(self, packet_runner):
        self.apply_dml_file(self.sql_planta_de_dbms, self.sql_script)
        return self.success()
