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

from ppms.migration.packet import *


class InsertSQLStmtForFillTempTable(SQLPacket):
    '''Inserts a SQL Statement required by function fill_temp_table in project_rights.py'''
    version = 1
    done_after_success = True
    run_on_startup = True
    category = PacketCategory.CATEGORY_MANDATORY
    wi_number = 10662

    fname = 'wi10662_filltemptable_edits_max_1000_projects.sql'

    def fix(self, runner):
        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()