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

class AddDateShiftProcedure(SQLPacket):
    """Adds the procedure P_ShiftDate which is used to shift date values.
    This is a PLANTA internal procedure and not meant for custom use."""
    done_after_success = True
    run_on_startup = True
    category = PacketCategory.CATEGORY_MANDATORY
    wi_number = 16815

    sql_script = 'WI16815_add_p_shiftdate.sql'

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

    def fix(self, packet_runner):
        self.apply_dml_file(self.sql_planta_de_dbms, self.sql_script,
                            split=False)

        return self.success()