def forwards(self, orm):
        if db.dry_run:
            return

        Thumb = orm['cropduster.Thumb']
        Image = orm['cropduster.Image']
        M2M = Image.thumbs.through

        auto_thumbs = Thumb.objects.filter(reference_thumb__isnull=False)
        for auto_thumb in auto_thumbs:
            images = M2M.objects.filter(thumb_id__exact=auto_thumb.reference_thumb_id)
            if 1 > len(images):
                for image in images[1:]:
                    image.delete()
            try:
                thumb_image = images[0]
            except IndexError:
                pass
            else:
                auto_m2m, created = M2M.objects.get_or_create(thumb=auto_thumb, image=thumb_image.image)
dataset/ETHPy150Open theatlantic/django-cropduster/cropduster/south_migrations/0004_add_auto_thumb_m2m_rows.py/Migration.forwards/swapped operands of `>`