# Generated by Django 2.2.4 on 2020-08-18 15:19

from django.db import migrations


def fill_owners(apps, schema_editor):
    flats = apps.get_model('property', 'Flat')
    owners = apps.get_model('property', 'Owner')
    for flat in flats.objects.all():
        flat_owner, created = owners.objects.get_or_create(
            owner_name=flat.owner,
            owner_phone_pure=flat.owner_phone_pure)
        flat_owner.owners_flats.add(flat)


class Migration(migrations.Migration):
    dependencies = [
        ('property', '0010_auto_20200818_0544'),
    ]

    operations = [
        migrations.RunPython(fill_owners),
    ]
