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


class AddPulseFlagForWebInterfaces(SQLPacket):
    """Add a flag for web interfaces"""
    run_on_startup = True
    done_after_success = True
    category = PacketCategory.CATEGORY_MANDATORY
    wi_number = 21604

    sql_script = 'WI22130_pulse_flag.sql'

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

    def fix(self, runner):
        if self.column_exists(table_name='WEBINTERFACE', column_name='PULSE'):
            self.log('Column already exists!')
        else:
            self.apply_dml_file(self.sql_planta_de_dbms, self.sql_script)

        return self.success()
