# Generated by Django 4.2.1 on 2023-10-12 11:53

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):
    dependencies = [
        ("receipe", "0052_alter_purchase_edit_finished"),
    ]

    operations = [
        migrations.CreateModel(
            name="Nutrient",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "name",
                    models.CharField(
                        max_length=50, unique=True, verbose_name="nutrient name"
                    ),
                ),
                (
                    "isMacroNutrient",
                    models.BooleanField(
                        default=False, verbose_name="Is macronutrient?"
                    ),
                ),
            ],
        ),
        migrations.CreateModel(
            name="NutrientArticle",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "value",
                    models.DecimalField(
                        blank=True,
                        decimal_places=2,
                        max_digits=7,
                        null=True,
                        verbose_name="value",
                    ),
                ),
                ("unit", models.CharField(blank=True, max_length=4, null=True)),
                (
                    "isEstimated",
                    models.BooleanField(
                        default=False, verbose_name="Is nutrient exstimated?"
                    ),
                ),
                (
                    "article",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        to="receipe.article",
                        verbose_name="article",
                    ),
                ),
                (
                    "nutrient",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        to="receipe.nutrient",
                        verbose_name="nutrient",
                    ),
                ),
            ],
        ),
        migrations.AddField(
            model_name="article",
            name="nutrients",
            field=models.ManyToManyField(
                blank=True, through="receipe.NutrientArticle", to="receipe.nutrient"
            ),
        ),
    ]
