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


class MoveLogUnsupportedKoAGrCU(SQLPacket):
    """updates the python path in the migration table to the new path of LogUnsupportedKoAGrCU"""
    done_after_success = True
    run_on_startup = True
    category = PacketCategory.CATEGORY_MANDATORY
    wi_number = 19079

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

    def fix(self, packet_runner):

        query="""UPDATE MIGRATIONRULE
            SET PYTHONPATH = 'migration.after_db_import.DB_39_5_9.WI9158_log_unsupported_koagr_cu.LogUnsupportedKoAGrCU'
            WHERE PYTHONPATH = 'migration.customizing.DB_39_5_2.WI9158_log_unsupported_koagr_cu.LogUnsupportedKoAGrCU'"""
        self.modify_and_log(query)
        return self.success()

