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

PACKET_PATH = 'migration.server.DB_39_5_4.WI17007_ChangeColumnLengthForDT810and812'

class ChangeColumnLengthForDT810and812(SQLPacket):

    "Modify column length for DT810 DI007711 and DT812 DI029571"

    done_after_success = True
    run_on_startup = True
    category = PacketCategory.CATEGORY_MANDATORY
    wi_number = 17007

    STATEMENTS = {DBMS_ORACLE: ("alter table dt810 modify di007711 VARCHAR2(50 CHAR)",
                                 "alter table dt812 modify di029571 VARCHAR2(50 CHAR)"),}

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

    def fix(self, runner):
        if ppms.db_get_dbms_name() == DBMS_ORACLE:
            for statement in self.STATEMENTS[DBMS_ORACLE]:
                self.modify_and_log(statement)
            
            return self.success()
            
        if ppms.db_get_dbms_name() == DBMS_MSSQL:
        
            return self.success()
