# Generated by Django 4.2.12 on 2024-10-13 05:52

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


class Migration(migrations.Migration):

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ('alkatorapi', '0018_profile_phone'),
    ]

    operations = [
        migrations.CreateModel(
            name='Cart',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
            ],
        ),
        migrations.CreateModel(
            name='Invoice',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('invoice_id', models.IntegerField(unique=True)),
                ('total_price', models.IntegerField()),
                ('paid_date', models.DateTimeField(auto_now=True)),
                ('paid', models.BooleanField(default=False)),
                ('trans_id', models.CharField(blank=True, max_length=120, null=True)),
                ('address', models.CharField(blank=True, max_length=255, null=True)),
            ],
        ),
        migrations.CreateModel(
            name='Product',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=120)),
                ('description', models.TextField()),
                ('img', models.CharField(max_length=120)),
                ('price', models.IntegerField()),
                ('quantity', models.IntegerField()),
            ],
        ),
        migrations.RemoveField(
            model_name='racer',
            name='id',
        ),
        migrations.RemoveField(
            model_name='racer',
            name='invoice_id',
        ),
        migrations.RemoveField(
            model_name='racer',
            name='paid',
        ),
        migrations.RemoveField(
            model_name='racer',
            name='price',
        ),
        migrations.RemoveField(
            model_name='racer',
            name='register_date',
        ),
        migrations.RemoveField(
            model_name='racer',
            name='trans_id',
        ),
        migrations.AlterField(
            model_name='racer',
            name='profile',
            field=models.ForeignKey(on_delete=django.db.models.deletion.RESTRICT, related_name='racers', to='alkatorapi.profile'),
        ),
        migrations.CreateModel(
            name='InvoiceProduct',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('quantity', models.IntegerField()),
                ('price', models.IntegerField(default=1)),
                ('invoice', models.ForeignKey(on_delete=django.db.models.deletion.RESTRICT, to='alkatorapi.invoice')),
                ('product', models.ForeignKey(on_delete=django.db.models.deletion.RESTRICT, to='alkatorapi.product')),
            ],
            options={
                'unique_together': {('product', 'invoice')},
            },
        ),
        migrations.AddField(
            model_name='invoice',
            name='items',
            field=models.ManyToManyField(through='alkatorapi.InvoiceProduct', to='alkatorapi.product'),
        ),
        migrations.AddField(
            model_name='invoice',
            name='user',
            field=models.ForeignKey(on_delete=django.db.models.deletion.RESTRICT, to=settings.AUTH_USER_MODEL),
        ),
        migrations.CreateModel(
            name='CartProduct',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('quantity', models.IntegerField()),
                ('cart', models.ForeignKey(on_delete=django.db.models.deletion.RESTRICT, to='alkatorapi.cart')),
                ('product', models.ForeignKey(on_delete=django.db.models.deletion.RESTRICT, to='alkatorapi.product')),
            ],
            options={
                'unique_together': {('product', 'cart')},
            },
        ),
        migrations.AddField(
            model_name='cart',
            name='items',
            field=models.ManyToManyField(through='alkatorapi.CartProduct', to='alkatorapi.product'),
        ),
        migrations.AddField(
            model_name='cart',
            name='user',
            field=models.ForeignKey(on_delete=django.db.models.deletion.RESTRICT, to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='racer',
            name='invoiceproduct_ptr',
            field=models.OneToOneField(auto_created=True, default=1, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='alkatorapi.invoiceproduct'),
            preserve_default=False,
        ),
    ]
