# Generated by Django 2.2.4 on 2019-10-16 11:33

from django.db import migrations, models


def fill_establishment_type(apps, schema_editor):
    # We can't import the Person model directly as it may be a newer
    # version than this migration expects. We use the historical version.
    EstablishmentType = apps.get_model('establishment', 'EstablishmentType')
    for n, et in enumerate(EstablishmentType.objects.all()):
        et.index_name = f'Type {n}'
        et.save()


class Migration(migrations.Migration):

    dependencies = [
        ('establishment', '0037_auto_20191015_1404'),
    ]

    operations = [
        migrations.AddField(
            model_name='establishmenttype',
            name='index_name',
            field=models.CharField(blank=True, db_index=True, max_length=50, null=True, unique=True, default=None, verbose_name='Index name'),
        ),
        migrations.RunPython(fill_establishment_type, migrations.RunPython.noop),
        migrations.AlterField(
            model_name='establishmenttype',
            name='index_name',
            field=models.CharField(choices=[('restaurant', 'Restaurant'), ('artisan', 'Artisan'),
                                            ('producer', 'Producer')], db_index=True, max_length=50,
                                   unique=True, verbose_name='Index name'),
        ),
    ]
