# Generated by Django 3.1.3 on 2020-12-14 18:55

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='Books',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('title', models.CharField(max_length=100, verbose_name='Оглавление')),
                ('text', models.TextField(verbose_name='Текст книги')),
                ('published', models.DateTimeField(auto_now_add=True, verbose_name='Время публикации')),
                ('buyers', models.ManyToManyField(to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'verbose_name': 'Книга',
                'verbose_name_plural': 'Книги',
            },
        ),
        migrations.CreateModel(
            name='Comment',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('text', models.TextField(verbose_name='Комментарий')),
                ('comment_date', models.DateTimeField(auto_now_add=True)),
            ],
            options={
                'verbose_name': 'Комментарий',
                'verbose_name_plural': 'Комментарии',
            },
        ),
        migrations.CreateModel(
            name='Genre',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('genre', models.CharField(max_length=100, verbose_name='Жанр')),
            ],
            options={
                'verbose_name': 'Жанр ',
                'verbose_name_plural': 'Жанры',
            },
        ),
        migrations.CreateModel(
            name='Pub_office',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('publisher', models.CharField(max_length=100, verbose_name='Издатель')),
            ],
            options={
                'verbose_name': 'Издательства',
                'verbose_name_plural': 'Издательства',
            },
        ),
        migrations.CreateModel(
            name='CommentLikes',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('comment', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='likes', to='manager.comment')),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='comment_like', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'unique_together': {('comment', 'user')},
            },
        ),
        migrations.AddField(
            model_name='comment',
            name='author_comment',
            field=models.ManyToManyField(related_name='comment_likers', through='manager.CommentLikes', to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='comment',
            name='book',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='comment', to='manager.books'),
        ),
        migrations.AddField(
            model_name='comment',
            name='name',
            field=models.ManyToManyField(to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='books',
            name='genre',
            field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='manager.genre', verbose_name='Жанр'),
        ),
        migrations.AddField(
            model_name='books',
            name='shop',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='manager.pub_office'),
        ),
        migrations.CreateModel(
            name='BookRating',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('rate', models.SmallIntegerField(default=0, verbose_name='Суммарный рейтинг')),
                ('book', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='user_rate', to='manager.books')),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='book_rate', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'unique_together': {('book', 'user')},
            },
        ),
    ]
