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


class AddMaxHoursColumnToEmployeePool(SQLPacket):
    """Adds max hours per day column to the employee pool table."""
    run_on_startup = True
    done_after_success = True
    category = PacketCategory.CATEGORY_MANDATORY
    wi_number = 22158

    sql_script = 'WI22158_add_max_hours_column.sql'

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

    def fix(self, runner):
        if self.column_exists('MITARBEITER_POOL', 'MAX_HOURS'):
            self.log('The max hours column already exists. Nothing to do.')
            return self.success()

        self.apply_dml_file(self.sql_planta_de_dbms, self.sql_script)

        return self.success()
