# Generated by Django 3.2.10 on 2022-01-05 13:58

from django.conf import settings
from django.db import migrations, models

from cookbook.models import FoodInheritField


def rename_inherit_field(apps, schema_editor):
    x = FoodInheritField.objects.filter(name='On Hand', field='food_onhand').first()
    if x:
        x.name = "Ignore Shopping"
        x.field = "ignore_shopping"
        x.save()


class Migration(migrations.Migration):

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ('cookbook', '0162_userpreference_csv_delim'),
    ]

    operations = [
        migrations.AddField(
            model_name='food',
            name='onhand_users',
            field=models.ManyToManyField(blank=True, to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='userpreference',
            name='shopping_add_onhand',
            field=models.BooleanField(default=True),
        ),
        migrations.RenameField(
            model_name='food',
            old_name='food_onhand',
            new_name='ignore_shopping',
        ),
        migrations.RunPython(rename_inherit_field),
    ]
