# -*- coding: utf-8 -*-
from ppms.constants import *

from ppms.migration import SQLPacket, PacketCategory, MaxVersionDependency


class ExtendPSPNameColumn(SQLPacket):
    """Extend the psp_name column in DT 964 to 50 characters"""
    done_after_success = True
    run_on_startup = True
    category = PacketCategory.CATEGORY_MANDATORY
    wi_number = 21576

    ALTER_TABLE_STATEMENTS = {DBMS_ORACLE: "ALTER TABLE SAPPOOL MODIFY PSP_NAME VARCHAR2(50)",
                              DBMS_MSSQL: "ALTER TABLE SAPPOOL ALTER COLUMN PSP_NAME VARCHAR(50)"}

    def get_dependencies(self):
        return MaxVersionDependency(version='39.5.10'),

    def fix(self, runner):
        self.modify_and_log(self.ALTER_TABLE_STATEMENTS[self.DBMS])

        return self.success()
