from ppms.migration import *
from ppms import ppms


class RemoveIncompletePlantaUsers(ChangeDTPPacket, SQLPacket):
    """Removes incomplete Planta users which may have been inserted by previous hotfix patches"""
    run_on_startup = True
    done_after_success = True
    category = PacketCategory.CATEGORY_MANDATORY
    wi_number = 19463

    def fix(self, packet_runner):
        ppms.db_modify("delete from dt511 where di010421 not in (select di010420 from dt516) and di010323 in ('YUSA', 'OLGA')")

        return self.success()
