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

class Correct_Licenses(SQLPacket):
    '''Corrects licenses of various tables (especially for counter value tables)

    Also gives all values of these tables a new UUID, to prevent PK clash at later import time'''
    version = 1
    run_on_startup = True
    done_after_success = True
    category = PacketCategory.CATEGORY_MANDATORY
    wi_number = 16800

    sql_file = 'wi16800_correct_licenses_and_uuid.sql'
    db_seperator = {DBMS_MSSQL: "GO",
                    DBMS_ORACLE: ";/"}

    def get_dependencies(self):
        return (MaxVersionDependency(version='39.5.7', version_type=VersionType.CUSTOMIZING))

    def fix(self, runner):
        self.apply_fix_ddl_file(self.sql_planta_de_dbms, self.sql_file, split=True, separator='GO')
        return self.success()

