# Generated by Django 3.1.2 on 2020-11-12 14:34

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


class Migration(migrations.Migration):

    initial = True

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

    operations = [
        migrations.CreateModel(
            name='Cafe',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=128, unique=True)),
                ('latitude', models.DecimalField(blank=True, decimal_places=2, max_digits=4, null=True)),
                ('longitude', models.DecimalField(blank=True, decimal_places=2, max_digits=4, null=True)),
                ('address', models.CharField(max_length=128)),
                ('average_rating', models.FloatField(blank=True, null=True)),
                ('description', models.TextField(blank=True, null=True)),
                ('registration_code', models.CharField(max_length=32)),
            ],
        ),
        migrations.CreateModel(
            name='Consumer',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('favourite_cafes', models.ManyToManyField(blank=True, related_name='consumers_favourite', to='api.Cafe')),
                ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='consumer', to=settings.AUTH_USER_MODEL)),
            ],
        ),
        migrations.CreateModel(
            name='Order',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('order_num', models.CharField(default=0, max_length=16, verbose_name='Номер заказа')),
                ('total_sum', models.DecimalField(blank=True, decimal_places=2, default=0, max_digits=8)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('ready_at', models.DateTimeField(blank=True, null=True)),
                ('completed_at', models.DateTimeField(blank=True, null=True)),
                ('status', models.CharField(max_length=32)),
                ('cafe', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='orders', to='api.cafe')),
                ('consumer', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='orders', to='api.consumer')),
            ],
        ),
        migrations.CreateModel(
            name='Product',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=128)),
                ('price', models.DecimalField(decimal_places=2, max_digits=7)),
                ('image_src', models.URLField(blank=True, null=True)),
                ('is_available', models.BooleanField(blank=True, null=True)),
                ('has_options', models.BooleanField()),
                ('on_menu', models.BooleanField(default=False)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('cafe', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='products', to='api.cafe')),
            ],
        ),
        migrations.CreateModel(
            name='ProductOption',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=128)),
                ('product', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='options', to='api.product')),
            ],
        ),
        migrations.CreateModel(
            name='ProductOptionChoice',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=128)),
                ('price', models.DecimalField(decimal_places=2, max_digits=6)),
                ('is_available', models.BooleanField(blank=True, null=True)),
                ('is_default', models.BooleanField()),
                ('product_option', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='choices', to='api.productoption')),
            ],
        ),
        migrations.CreateModel(
            name='OrderedProduct',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('quantity', models.PositiveSmallIntegerField(default=1)),
                ('chosen_options', models.ManyToManyField(blank=True, related_name='ordered_products', to='api.ProductOptionChoice')),
                ('order', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='ordered_products', to='api.order')),
                ('product', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='ordered_products', to='api.product')),
            ],
        ),
        migrations.CreateModel(
            name='Employee',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('cafe', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='employees', to='api.cafe')),
                ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='employee', to=settings.AUTH_USER_MODEL)),
            ],
        ),
        migrations.CreateModel(
            name='CafeRating',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('value', models.FloatField(choices=[(1.0, 1.0), (1.5, 1.5), (2.0, 2.0), (2.5, 2.5), (3.0, 3.0), (3.5, 3.5), (4.0, 4.0), (4.5, 4.5), (5.0, 5.0)])),
                ('cafe', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='ratings', to='api.cafe')),
                ('consumer', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='ratings', to='api.consumer')),
            ],
        ),
        migrations.CreateModel(
            name='CafePhoto',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('image_src', models.URLField()),
                ('cafe', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='photos', to='api.cafe')),
            ],
        ),
    ]
