# Generated by Django 5.0.9 on 2025-01-02 14:23

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


class Migration(migrations.Migration):

    dependencies = [
        ("atoum", "0001_initial"),
    ]

    operations = [
        migrations.CreateModel(
            name="Shopping",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "created",
                    models.DateTimeField(
                        db_index=True,
                        default=django.utils.timezone.now,
                        verbose_name="creation date",
                    ),
                ),
                (
                    "planning",
                    models.DateTimeField(
                        db_index=True,
                        default=django.utils.timezone.now,
                        verbose_name="planning date",
                    ),
                ),
                (
                    "title",
                    models.CharField(
                        default="", max_length=100, unique=True, verbose_name="title"
                    ),
                ),
            ],
            options={
                "verbose_name": "Shopping",
                "verbose_name_plural": "Shoppings",
                "ordering": ["title"],
            },
        ),
        migrations.CreateModel(
            name="ShoppingItem",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "created",
                    models.DateTimeField(
                        default=django.utils.timezone.now, verbose_name="creation date"
                    ),
                ),
                ("quantity", models.PositiveSmallIntegerField(verbose_name="quantity")),
                (
                    "done",
                    models.BooleanField(blank=True, default=False, verbose_name="done"),
                ),
                (
                    "product",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE, to="atoum.product"
                    ),
                ),
                (
                    "shopping",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE, to="atoum.shopping"
                    ),
                ),
            ],
            options={
                "verbose_name": "Shopping item",
                "verbose_name_plural": "Shopping items",
                "ordering": ["shopping", "product"],
            },
        ),
        migrations.AddField(
            model_name="shopping",
            name="products",
            field=models.ManyToManyField(
                blank=True,
                related_name="shoppings",
                through="atoum.ShoppingItem",
                to="atoum.product",
                verbose_name="items",
            ),
        ),
        migrations.DeleteModel(
            name="Article",
        ),
        migrations.DeleteModel(
            name="Blog",
        ),
        migrations.AddConstraint(
            model_name="shoppingitem",
            constraint=models.UniqueConstraint(
                fields=("shopping", "product"),
                name="atoum_unique_shoppingitem_shopping_product",
            ),
        ),
    ]
