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


class AddNewEffectTypeBlank(SQLPacket):
    """Adds the new effect type 'blank' to listbox Effekte"""
    run_on_startup = True
    done_after_success = True
    category = PacketCategory.CATEGORY_MANDATORY
    wi_number = 20161

    filename = 'WI20161_add_blank_effect_type.sql'
    deletion_file = 'WI20161_add_blank_effect_type_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()
