# Generated by Django 5.0.4 on 2024-04-23 08:54

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


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name="Group",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                (
                    "entry_price",
                    models.DecimalField(decimal_places=2, max_digits=10),
                ),
                (
                    "unit_price",
                    models.DecimalField(decimal_places=2, max_digits=10),
                ),
                (
                    "wholesale_price",
                    models.DecimalField(decimal_places=2, max_digits=10),
                ),
                ("quantity", models.IntegerField()),
                ("broken_eggs", models.IntegerField()),
            ],
            options={
                "verbose_name": "Group",
                "verbose_name_plural": "Groups",
                "db_table": "group",
            },
        ),
        migrations.CreateModel(
            name="Location",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                ("long", models.BigIntegerField()),
                ("lat", models.BigIntegerField()),
                ("label", models.TextField()),
            ],
            options={
                "verbose_name": "Location",
                "verbose_name_plural": "Locations",
                "db_table": "location",
            },
        ),
        migrations.CreateModel(
            name="Product",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                ("name", models.CharField(max_length=255)),
            ],
            options={
                "verbose_name": "Product",
                "verbose_name_plural": "Products",
                "db_table": "product",
            },
        ),
        migrations.CreateModel(
            name="Courier",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                (
                    "user_id",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="couriers",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "verbose_name": "Courier",
                "verbose_name_plural": "Couriers",
                "db_table": "courier",
            },
        ),
        migrations.CreateModel(
            name="CourierProduct",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                ("count", models.IntegerField()),
                (
                    "courier_id",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="courier_products",
                        to="eggs.courier",
                    ),
                ),
                (
                    "group_id",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="courier_groups",
                        to="eggs.group",
                    ),
                ),
            ],
            options={
                "verbose_name": "CourierProduct",
                "verbose_name_plural": "CourierProducts",
                "db_table": "courier_product",
            },
        ),
        migrations.CreateModel(
            name="Market",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                ("name", models.CharField(max_length=255)),
                (
                    "avatar",
                    models.ImageField(
                        blank=True, null=True, upload_to="market_avatar/"
                    ),
                ),
                ("phone", models.CharField(max_length=20)),
                (
                    "location",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="market_location",
                        to="eggs.location",
                    ),
                ),
                (
                    "user_id",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "verbose_name": "Market",
                "verbose_name_plural": "Markets",
                "db_table": "market",
            },
        ),
        migrations.CreateModel(
            name="Order",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                ("data", models.DateField(auto_now=True)),
                (
                    "status",
                    models.CharField(
                        choices=[
                            ("delivery", "Delivery"),
                            ("pending", "Pending"),
                            ("success", "Success"),
                            ("cancel", "Cancel"),
                            ("done", "Done"),
                        ],
                        default="pending",
                        max_length=255,
                    ),
                ),
                ("comment", models.TextField(blank=True, null=True)),
                (
                    "price",
                    models.DecimalField(decimal_places=2, max_digits=10),
                ),
                (
                    "price_paid",
                    models.DecimalField(decimal_places=2, max_digits=10),
                ),
                (
                    "courier_id",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="orders",
                        to="eggs.courier",
                    ),
                ),
                (
                    "location_id",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="eggs.location",
                    ),
                ),
                (
                    "market_id",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="orders",
                        to="eggs.market",
                    ),
                ),
            ],
            options={
                "verbose_name": "Order",
                "verbose_name_plural": "Orders",
                "db_table": "order",
            },
        ),
        migrations.CreateModel(
            name="Party",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                (
                    "price",
                    models.DecimalField(decimal_places=2, max_digits=10),
                ),
                (
                    "user_id",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="parties",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "verbose_name": "Party",
                "verbose_name_plural": "Parties",
                "db_table": "party",
            },
        ),
        migrations.CreateModel(
            name="Invoice",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("name", models.CharField(max_length=256)),
                (
                    "price",
                    models.DecimalField(decimal_places=2, max_digits=10),
                ),
                (
                    "party_id",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="invoices",
                        to="eggs.party",
                    ),
                ),
            ],
            options={
                "verbose_name": "Invoice",
                "verbose_name_plural": "Invoices",
                "db_table": "invoice",
            },
        ),
        migrations.AddField(
            model_name="group",
            name="party_id",
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE, to="eggs.party"
            ),
        ),
        migrations.CreateModel(
            name="CourierHistory",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                ("get_eggs", models.IntegerField()),
                ("return_eggs", models.IntegerField(blank=True, null=True)),
                ("broken_eggs", models.IntegerField(blank=True, null=True)),
                ("date", models.DateField(auto_now=True, null=True)),
                (
                    "group_id",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="eggs.group",
                    ),
                ),
                (
                    "courier_id",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="courier_histories",
                        to="eggs.party",
                    ),
                ),
            ],
            options={
                "verbose_name": "CourierHistory",
                "verbose_name_plural": "CourierHistories",
                "db_table": "courier_history",
            },
        ),
        migrations.CreateModel(
            name="OrderItems",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                ("count", models.IntegerField()),
                ("discount", models.IntegerField()),
                (
                    "courier_product_id",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="eggs.courierproduct",
                    ),
                ),
                (
                    "product_id",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="eggs.product",
                    ),
                ),
            ],
            options={
                "verbose_name": "OrderItem",
                "verbose_name_plural": "OrderItems",
                "db_table": "order_item",
            },
        ),
        migrations.AddField(
            model_name="group",
            name="product_id",
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                related_name="groups",
                to="eggs.product",
            ),
        ),
    ]
