# Generated by Django 3.1.4 on 2021-01-02 17:31

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


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('account', '0001_initial'),
    ]

    operations = [
        migrations.CreateModel(
            name='Order',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('address', models.CharField(max_length=250, null=True)),
                ('city', models.CharField(max_length=100, null=True)),
                ('reference_id', models.CharField(blank=True, max_length=128)),
                ('status', models.IntegerField(choices=[(0, 'standing'), (1, 'cancelled'), (2, 'paid'), (3, 'delivered')], default=0)),
                ('paid', models.BooleanField(default=False)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('customer', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='account.customer')),
            ],
            options={
                'db_table': 'order',
            },
        ),
        migrations.CreateModel(
            name='Shop',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=500)),
                ('description', models.CharField(blank=True, max_length=256)),
                ('sub_domain', models.CharField(max_length=128, unique=True)),
                ('delivery_fee', models.IntegerField()),
                ('logo', models.ImageField(blank=True, null=True, upload_to='shoplogo/')),
                ('banner_image', models.ImageField(blank=True, null=True, upload_to='banner/')),
                ('is_active', models.BooleanField(default=False)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('rider', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='account.rider')),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='shop', to='account.merchant')),
            ],
            options={
                'db_table': 'shop',
            },
        ),
        migrations.CreateModel(
            name='ShopCategory',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=64)),
                ('slug', models.SlugField(default='', editable=False, max_length=200)),
                ('is_active', models.BooleanField(default=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('shop', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='merchant.shop')),
            ],
            options={
                'db_table': 'shopcategory',
            },
        ),
        migrations.CreateModel(
            name='Product',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=256)),
                ('price', models.IntegerField()),
                ('description', models.CharField(blank=True, max_length=256)),
                ('slug', models.SlugField(default='', editable=False, max_length=200)),
                ('image', models.ImageField(blank=True, null=True, upload_to='shop/')),
                ('is_active', models.BooleanField(default=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('shop', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='merchant.shop')),
                ('shopcategory', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='merchant.shopcategory')),
            ],
            options={
                'db_table': 'product',
            },
        ),
        migrations.CreateModel(
            name='OrderedItem',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('quantity', models.PositiveIntegerField(default=1)),
                ('item_price', models.DecimalField(decimal_places=2, max_digits=12)),
                ('order', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='items', to='merchant.order')),
                ('product', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='order_items', to='merchant.product')),
            ],
            options={
                'db_table': 'ordereditem',
                'unique_together': {('product', 'order')},
            },
        ),
        migrations.AddField(
            model_name='order',
            name='order_items',
            field=models.ManyToManyField(related_name='orders', through='merchant.OrderedItem', to='merchant.Product'),
        ),
        migrations.AddField(
            model_name='order',
            name='rider',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='account.rider'),
        ),
        migrations.AddField(
            model_name='order',
            name='shop',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='merchant.shop'),
        ),
    ]
