# Generated by Django 2.2.12 on 2020-08-09 19:17

from django.db import migrations


def rename(apps, schema_editor):
    if schema_editor.connection.alias != "default":
        return
    Member = apps.get_model("members", "Member")
    for member in Member.objects.all():
        if member.name:
            name_parts = member.name.rsplit(maxsplit=1)
            if len(name_parts) == 1:
                name_parts = name_parts + name_parts
            member.direct_address_name = name_parts[0]
            member.order_name = name_parts[1]
            member.save()


class Migration(migrations.Migration):
    dependencies = [
        ("members", "0011_auto_20200809_1916"),
    ]

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