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


class DeleteWrongOLEs(SQLPacket):
    """Delete OLEs with autonumbers starting with '100' as they should not exist"""
    done_after_success = True
    run_on_startup = True
    category = PacketCategory.CATEGORY_MANDATORY
    wi_number = 17341

    DELETE_STATEMENT = """delete from DT397
                        where DI008060 in ('100000001', '100000002', '100000003',
                         '100000004', '100000005')"""

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

    def fix(self, packet_runner):
        self.modify_and_log(self.DELETE_STATEMENT)
        return self.success()