new_contents: # -*- coding: utf-8 -*-
  # Generated by Django 1.11.15 on 2018-11-08 16:56
  from __future__ import unicode_literals
  
  from django.db import migrations
  from osf.models import Collection
  from django.contrib.contenttypes.models import ContentType
  
  
  def reverse_func(state, schema):
      preprint_content_type = ContentType.objects.get(app_label='osf', model='preprint')
      collections = Collection.objects.filter(collected_types__in=[preprint_content_type.id])
      for collection in collections:
          collection.collected_types.remove(preprint_content_type)
  
  
  def add_preprint_type_to_collections(state, schema):
      preprint_content_type = ContentType.objects.get(app_label='osf', model='preprint')
      collections = Collection.objects.exclude(collected_types__in=[preprint_content_type.id])
      for collection in collections:
          collection.collected_types.add(preprint_content_type)
  
  
  class Migration(migrations.Migration):
  
      dependencies = [
          ('osf', '0143_merge_20181023_1807'),
      ]
  
      operations = [
          migrations.RunPython(add_preprint_type_to_collections, reverse_func)
      ]
  
subject: Add data migration so preprints can be added to existing collections.