# Generated by Django 2.2.24 on 2021-09-15 15:20

from django.db import migrations


def change_content_type(apps, schema_editor):
    Poll = apps.get_model('a4polls', 'Poll')
    Action = apps.get_model('a4actions', 'Action')
    ContentType = apps.get_model('contenttypes', 'ContentType')
    mb_poll_content_type = ContentType.objects.get(model='mbpoll')
    poll_content_type = ContentType.objects.get_for_model(Poll)
    actions = Action.objects.filter(target_content_type_id=mb_poll_content_type.id)
    for action in actions:
        action.target_content_type = poll_content_type
        action.save()

class Migration(migrations.Migration):

    dependencies = [
        ('meinberlin_polls', '0008_delete_mbpoll'),
    ]

    operations = [
        migrations.RunPython(change_content_type)
    ]

make sure actions have the new a4 poll as content type