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


class PortNewDialogModuleParameters(SQLPacket):
    """Port 2 new dialog module parameters: height and width"""
    run_on_startup = True
    done_after_success = True
    category = PacketCategory.CATEGORY_MANDATORY
    wi_number = 19185

    filename = 'wi19185_dialog_module.sql'
    deletion_file = 'wi19185_dialog_module_delete.sql'

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

    def delete_old_data(self):
        self.log_heading('Wiping data that could cause conflicts')
        self.apply_dml_file(self.sql_planta_de_ansi, self.deletion_file)

    def insert_new_data(self):
        self.log_heading('Inserting new data')
        self.apply_dml_file(self.sql_planta_de_dbms, self.filename)

    def fix(self, runner):
        with ppms.autocommit_disabled():
            self.delete_old_data()
            self.insert_new_data()

        return self.success()
