# -*- coding: utf-8 -*-

from ppms.migration import SQLPacket, PacketCategory, MinVersionDependency, MaxVersionDependency


class AddProfilingTables(SQLPacket):
    """Add the profiling tables"""
    done_after_success = True
    run_on_startup = True
    category = PacketCategory.CATEGORY_MANDATORY
    wi_number = 18807

    sql_script = 'wi18807_profiling_tables.sql'

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

    def fix(self, packet_runner):
        if not self.column_exists(table_name='PYTHONPERFORMANCE', column_name='UUID'):
            self.apply_fix_ddl_file(self.sql_planta_de_dbms, self.sql_script, split=True)

        return self.success()
