# Generated by Django 2.2.9 on 2020-01-27 21:19

from django.db import migrations


def attach_memberships_to_posts(apps, schema_editor):
    Membership = apps.get_model("popolo", "Membership")
    for membership in Membership.objects.all():
        if membership.post != membership.ballot.post:
            membership.post = membership.ballot.post
            membership.save()


class Migration(migrations.Migration):

    dependencies = [("popolo", "0034_populate_from_ee_divisions")]

    operations = [
        migrations.RunPython(
            attach_memberships_to_posts, migrations.RunPython.noop
        )
    ]

Set all membership.post objects to membership.ballot.post
Set all membership.post objects to membership.ballot.post
