# -*- coding: utf-8 -*-
from ppms import ppms
from ppms.migration.packet import *
from . import DEFAULT_CUSTOMIZING_DEPENDENCY


class PortInterfaceTextConstants(SQLPacket):
    '''Port new text constants for the PLANTA Link from Venus
    
    Also delete some obsolete text constants
    '''
    version = 1
    done_after_success = True
    run_on_startup = True
    category = PacketCategory.CATEGORY_MANDATORY
    wi_number = 12062

    fname = 'WI12062_interface_text_constants.sql'

    def get_dependencies(self):
        return DEFAULT_CUSTOMIZING_DEPENDENCY

    def fix(self, runner):
        self.apply_dml_file(self.sql_planta_de_dbms, self.fname)

        for text_constant in ('001660', '001661'):
            constant_record = ppms.search_record(425, [text_constant], ['no_id'], True)
            constant_record.delete()

        return self.success()
