# -*- coding: utf-8 -*-
import os

from ppms import ppms
from ppms.migration.packet import *


class AddObjectRightsToHumanResourcesInterface(SQLPacket):
    '''Adds DI 063006 to the human resources pool table'''
    version = 1
    done_after_success = True
    run_on_startup = True
    category = PacketCategory.CATEGORY_MANDATORY
    wi_number = 12019

    fname = 'wi12019_object_rights.sql'

    DBMS_QUERY = {'000002': 'alter table MITARBEITER_POOL add MULTI_PR_MANAGER varchar2(20 char)',
                  '000004': 'alter table MITARBEITER_POOL add MULTI_PR_MANAGER varchar(20)'}

    def fix(self, runner):
        query = self.DBMS_QUERY[ppms.db_get_dbms_name()]
        self.modify_and_log(query)

        sqlpath = self.get_sql_file_path(self.sql_planta_de_dbms, self.fname)
        queries = self.get_queries_from_file(sqlpath)

        for query in queries:
            self.modify_and_log(query)

        return self.success()
