new_contents: # Generated by Django 2.1.8 on 2019-04-10 17:32
  
  from django.db import migrations
  from django.db.models import Q
  
  def forward(apps, schema_editor):
      Appearance = apps.get_model('api.appearance')
      Round = apps.get_model('api.round')
      appearances = Appearance.objects.filter(
          draw__isnull=False,
          round__kind__gt=1,
          status=-10, # COmpleted
      ).exclude(
          draw=0,
      )
  
      for a in appearances:
          a.csa.delete(save=False)
          a.status = 40 # Advanced
          a.save()
  
  class Migration(migrations.Migration):
  
      dependencies = [
          ('api', '0118_auto_20190409_0930'),
      ]
  
      operations = [
          migrations.RunPython(forward),
      ]
  
subject: Clean up appearances migration