def populate_entity_type(apps, schema_editor):
    """Populate entity type from attached descriptor schema."""
    Entity = apps.get_model('flow', 'Entity')

    for entity in Entity.objects.all():
        if entity.descriptor_schema is not None:
            entity.type = entity.descriptor_schema.slug
            entity.save()
Populate entity type from attached descriptor schema.