def METHOD_NAME(apps, schema_editor):
    OldBadgeAssertion = apps.get_model("certificates", "BadgeAssertion")
    BadgeAssertion = apps.get_model("badges", "BadgeAssertion")
    BadgeImageConfiguration = apps.get_model("certificates", "BadgeImageConfiguration")
    CourseCompleteImageConfiguration = apps.get_model("badges", "CourseCompleteImageConfiguration")
    for badge in BadgeAssertion.objects.all():
        if not badge.badge_class.mode:
            # Can't preserve old badges without modes.
            continue
        if isinstance(badge.data, str):
            data = badge.data
        else:
            data = json.dumps(badge.data)
        OldBadgeAssertion(
            user_id=badge.user_id,
            course_id=badge.badge_class.course_id,
            mode=badge.badge_class.mode,
            data=data,
        ).save()
    for configuration in CourseCompleteImageConfiguration.objects.all():
        new_conf = BadgeImageConfiguration(
            default=configuration.default,
            mode=configuration.mode,
        )
        new_conf.icon.name = configuration.icon.name
        new_conf.save()