new_contents: # -*- coding: utf-8 -*-
  # Generated by Django 1.11.2 on 2017-07-25 17:16
  from __future__ import unicode_literals
  
  from django.conf import settings
  from django.db import migrations, models
  
  
  def migrate_user_guid_array_to_m2m(state, schema):
      from osf.models import OSFUser as FindableOSFUser
      AddableOSFUser = state.get_model('osf', 'osfuser')
      Comment = state.get_model('osf', 'comment')
      for comment in Comment.objects.exclude(_ever_mentioned=[]).all():
          for user in AddableOSFUser.objects.filter(id__in=[FindableOSFUser.objects.get(guids___id=_id).id for _id in comment._ever_mentioned]):
              comment.ever_mentioned.add(user)
          comment.save()
  
  def unmigrate_user_guid_array_from_m2m(state, schema):
      Comment = state.get_model('osf', 'comment')
      for comment in Comment.objects.exclude(ever_mentioned__isnull=False).all():
          comment._ever_mentioned = list(comment.ever_mentioned.values_list('guids___id', flat=True))
          comment.save()
  
  class Migration(migrations.Migration):
  
      dependencies = [
          ('osf', '0043_merge_20170725_1328'),
      ]
  
      operations = [
          migrations.RenameField(
              model_name='comment',
              old_name='ever_mentioned',
              new_name='_ever_mentioned'
          ),
          migrations.AddField(
              model_name='comment',
              name='ever_mentioned',
              field=models.ManyToManyField(blank=True, related_name='mentioned_in', to=settings.AUTH_USER_MODEL),
          ),
          migrations.RunPython(
              migrate_user_guid_array_to_m2m, unmigrate_user_guid_array_from_m2m
          ),
          migrations.RemoveField(
              model_name='comment',
              name='_ever_mentioned'
          ),
      ]
  
subject: Add migration