old_contents: # Generated by Django 2.2.24 on 2021-06-10 09:13
  
  from django.db import migrations
  from corehq.messaging.smsbackends.turn.models import SQLTurnWhatsAppBackend
  from corehq.toggles import TURN_IO_BACKEND, NAMESPACE_DOMAIN
  
  
  def auto_enable_turnio_ff_for_certain_domains(apps, schema_editor):
      for backend in SQLTurnWhatsAppBackend.active_objects.all():
          domain = backend.domain
          TURN_IO_BACKEND.set(item=domain, enabled=True, namespace=NAMESPACE_DOMAIN)
  
  
  def noop(apps, schema_editor):
      pass
  
  
  class Migration(migrations.Migration):
  
      dependencies = [
          ('sms', '0048_delete_sqlicdsbackend'),
      ]
  
      operations = [
          migrations.RunPython(auto_enable_turnio_ff_for_certain_domains, reverse_code=noop),
      ]
  
new_contents: # Generated by Django 2.2.24 on 2021-06-10 09:13
  
  from django.db import migrations
  from corehq.toggles import TURN_IO_BACKEND, NAMESPACE_DOMAIN
  
  
  def auto_enable_turnio_ff_for_certain_domains(apps, schema_editor):
      SQLTurnWhatsAppBackend = apps.get_model('sms', 'SQLTurnWhatsAppBackend')
  
      for backend in SQLTurnWhatsAppBackend.objects.all():
          # Check for backend.deleted to account for active_objects
          if not backend.deleted:
              domain = backend.domain
              TURN_IO_BACKEND.set(item=domain, enabled=True, namespace=NAMESPACE_DOMAIN)
  
  
  def noop(apps, schema_editor):
      pass
  
  
  class Migration(migrations.Migration):
  
      dependencies = [
          ('sms', '0048_delete_sqlicdsbackend'),
      ]
  
      operations = [
          migrations.RunPython(auto_enable_turnio_ff_for_certain_domains, reverse_code=noop),
      ]
  
subject: Use historical model in migration, not directly imported model