def migrate_old_comments(apps, schema_editor):
    # https://code.djangoproject.com/ticket/24282
    # If someone has a better solution until Django 1.8, would appreciate
    # a pull-request :)

    try:
        from django.contrib.comments.models import Comment as OldComment
    except __HOLE__:
        # Django > 1.7
        pass
    else:

        Comment = apps.get_model('document_comments', 'Comment')
        Document = apps.get_model('documents', 'Document')
        User = apps.get_model(*settings.AUTH_USER_MODEL.split('.'))

        for old_comment in OldComment.objects.all():
            comment = Comment(
                document=Document.objects.get(pk=old_comment.object_pk),
                user=User(old_comment.user.pk),
                comment=old_comment.comment,
                submit_date=old_comment.submit_date,
            )
            comment.save()
dataset/ETHPy150Open mayan-edms/mayan-edms/mayan/apps/document_comments/migrations/0003_auto_20150729_2144.py/migrate_old_comments