# Generated by Django 4.1.9 on 2023-05-25 13:05

import cookbook.models
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import django_prometheus.models


class Migration(migrations.Migration):

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ('cookbook', '0188_space_no_sharing_limit'),
    ]

    operations = [
        migrations.CreateModel(
            name='Property',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('property_amount', models.DecimalField(decimal_places=4, default=0, max_digits=32)),
            ],
            bases=(models.Model, cookbook.models.PermissionModelMixin),
        ),
        migrations.CreateModel(
            name='PropertyType',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=128)),
                ('unit', models.CharField(blank=True, max_length=64, null=True)),
                ('icon', models.CharField(blank=True, max_length=16, null=True)),
                ('description', models.CharField(blank=True, max_length=512, null=True)),
                ('category', models.CharField(blank=True, choices=[('NUTRITION', 'Nutrition'), ('ALLERGEN', 'Allergen'), ('PRICE', 'Price'), ('GOAL', 'Goal'), ('OTHER', 'Other')], max_length=64, null=True)),
                ('open_data_slug', models.CharField(blank=True, default=None, max_length=128, null=True)),
            ],
            bases=(models.Model, cookbook.models.PermissionModelMixin),
        ),
        migrations.CreateModel(
            name='UnitConversion',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('base_amount', models.DecimalField(decimal_places=16, default=0, max_digits=32)),
                ('converted_amount', models.DecimalField(decimal_places=16, default=0, max_digits=32)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('open_data_slug', models.CharField(blank=True, default=None, max_length=128, null=True)),
            ],
            bases=(django_prometheus.models.ExportModelOperationsMixin('unit_conversion'), models.Model, cookbook.models.PermissionModelMixin),
        ),
        migrations.AddField(
            model_name='food',
            name='fdc_id',
            field=models.CharField(blank=True, default=None, max_length=128, null=True),
        ),
        migrations.AddField(
            model_name='food',
            name='open_data_slug',
            field=models.CharField(blank=True, default=None, max_length=128, null=True),
        ),
        migrations.AddField(
            model_name='food',
            name='preferred_shopping_unit',
            field=models.ForeignKey(blank=True, default=None, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='preferred_shopping_unit', to='cookbook.unit'),
        ),
        migrations.AddField(
            model_name='food',
            name='preferred_unit',
            field=models.ForeignKey(blank=True, default=None, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='preferred_unit', to='cookbook.unit'),
        ),
        migrations.AddField(
            model_name='food',
            name='properties_food_amount',
            field=models.IntegerField(blank=True, default=100),
        ),
        migrations.AddField(
            model_name='food',
            name='properties_food_unit',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to='cookbook.unit'),
        ),
        migrations.AddField(
            model_name='supermarket',
            name='open_data_slug',
            field=models.CharField(blank=True, default=None, max_length=128, null=True),
        ),
        migrations.AddField(
            model_name='supermarketcategory',
            name='open_data_slug',
            field=models.CharField(blank=True, default=None, max_length=128, null=True),
        ),
        migrations.AddField(
            model_name='unit',
            name='base_unit',
            field=models.TextField(blank=True, default=None, max_length=256, null=True),
        ),
        migrations.AddField(
            model_name='unit',
            name='open_data_slug',
            field=models.CharField(blank=True, default=None, max_length=128, null=True),
        ),
        migrations.AddConstraint(
            model_name='supermarketcategoryrelation',
            constraint=models.UniqueConstraint(fields=('supermarket', 'category'), name='unique_sm_category_relation'),
        ),
        migrations.AddField(
            model_name='unitconversion',
            name='base_unit',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='unit_conversion_base_relation', to='cookbook.unit'),
        ),
        migrations.AddField(
            model_name='unitconversion',
            name='converted_unit',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='unit_conversion_converted_relation', to='cookbook.unit'),
        ),
        migrations.AddField(
            model_name='unitconversion',
            name='created_by',
            field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='unitconversion',
            name='food',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='cookbook.food'),
        ),
        migrations.AddField(
            model_name='unitconversion',
            name='space',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='cookbook.space'),
        ),
        migrations.AddField(
            model_name='propertytype',
            name='space',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='cookbook.space'),
        ),
        migrations.AddField(
            model_name='property',
            name='property_type',
            field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='cookbook.propertytype'),
        ),
        migrations.AddField(
            model_name='property',
            name='space',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='cookbook.space'),
        ),
        migrations.AddField(
            model_name='food',
            name='properties',
            field=models.ManyToManyField(blank=True, to='cookbook.property'),
        ),
        migrations.AddField(
            model_name='recipe',
            name='properties',
            field=models.ManyToManyField(blank=True, to='cookbook.property'),
        ),
        migrations.AddConstraint(
            model_name='unitconversion',
            constraint=models.UniqueConstraint(fields=('space', 'base_unit', 'converted_unit', 'food'), name='f_unique_conversion_per_space'),
        ),
        migrations.AddConstraint(
            model_name='propertytype',
            constraint=models.UniqueConstraint(fields=('space', 'name'), name='property_type_unique_name_per_space'),
        ),
    ]
