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


class TooManyOpenSessionsLocal(SQLPacket):
    '''Adds functionality that only allows a certain number of connections for every distinct user.
       This can be customized in new field called Parallel sessions in System-Customizer->Administration->Users'''
    version = 1
    done_after_success = True
    run_on_startup = True
    category = PacketCategory.CATEGORY_MANDATORY
    wi_number = 13213

    def get_dependencies(self):
        return (MaxVersionDependency('39.5.6'), )

    def fix(self, runner):
        file = 'WI13213_too_many_open_sessions_local.sql'

        self.apply_dml_file(self.sql_planta_de_dbms, file)

        return self.success()