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


class PortFilterMessages(SQLPacket):
    """
    Ports three dialog messages necessary for the filter functionality.
    """

    version = 1
    done_after_success = True
    run_on_startup = True
    category = PacketCategory.CATEGORY_MANDATORY
    wi_number = 16210

    sql_file = 'WI16210_port_messages_filter.sql'

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

    def fix(self, runner):
        if self.DBMS == DBMS_ORACLE:
            self.apply_fix_ddl_file(self.sql_planta_de_dbms, self.sql_file, split=True)
        else:
            self.apply_fix_ddl_file(self.sql_planta_de_dbms, self.sql_file, split=True, separator='GO')

        return self.success()