text: # Generated by Django 3.0.5 on 2021-01-23 10:30
  
  from django.conf import settings
  import django.core.validators
  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='Category',
              fields=[
                  ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                  ('name', models.CharField(db_index=True, max_length=20, verbose_name='Наименование')),
                  ('slug', models.SlugField(max_length=20, unique=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')),
                  ('name', models.CharField(db_index=True, max_length=20, verbose_name='Наименование')),
                  ('slug', models.SlugField(max_length=20, unique=True)),
              ],
              options={
                  'verbose_name': 'Жанр',
                  'verbose_name_plural': 'Жанры',
              },
          ),
          migrations.CreateModel(
              name='Title',
              fields=[
                  ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                  ('name', models.CharField(db_index=True, max_length=100, verbose_name='Название')),
                  ('year', models.PositiveSmallIntegerField(verbose_name='Год')),
                  ('description', models.TextField(blank=True, null=True, verbose_name='Описание')),
                  ('category', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='categories', to='api.Category', verbose_name='Категория')),
                  ('genre', models.ManyToManyField(blank=True, related_name='genres', to='api.Genre', verbose_name='Жанр')),
              ],
              options={
                  'verbose_name': 'Произведение',
                  'verbose_name_plural': 'Произведения',
                  'ordering': ('-id',),
              },
          ),
          migrations.CreateModel(
              name='Review',
              fields=[
                  ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                  ('text', models.TextField(verbose_name='текст')),
                  ('pub_date', models.DateTimeField(auto_now=True, verbose_name='дата создания')),
                  ('score', models.PositiveSmallIntegerField(validators=[django.core.validators.MinValueValidator(0), django.core.validators.MaxValueValidator(10)], verbose_name='оценка')),
                  ('author', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='reviews', to=settings.AUTH_USER_MODEL, verbose_name='автор')),
                  ('title', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='reviews', to='api.Title', verbose_name='произведение')),
              ],
              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='текст')),
                  ('pub_date', models.DateTimeField(auto_now=True, verbose_name='дата создания')),
                  ('author', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='comments', to=settings.AUTH_USER_MODEL, verbose_name='автор')),
                  ('review', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='comments', to='api.Review', verbose_name='отзыв')),
              ],
              options={
                  'verbose_name': 'комментарий',
                  'verbose_name_plural': 'комментарии',
              },
          ),
          migrations.AddConstraint(
              model_name='review',
              constraint=models.UniqueConstraint(fields=('title', 'author'), name='unique_review'),
          ),
      ]
  