# Generated by Django 2.2.7 on 2020-09-16 18:57

import ckeditor_uploader.fields
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='AnswerModel',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('content', ckeditor_uploader.fields.RichTextUploadingField()),
                ('vote', models.SmallIntegerField(default=0)),
                ('is_approved', models.BooleanField(default=False)),
                ('edited', models.BooleanField(default=False)),
                ('date', models.DateTimeField(auto_now_add=True)),
                ('author', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, related_name='author', to=settings.AUTH_USER_MODEL)),
            ],
        ),
        migrations.CreateModel(
            name='QuestionModel',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('title', models.CharField(max_length=200)),
                ('content', ckeditor_uploader.fields.RichTextUploadingField()),
                ('vote', models.SmallIntegerField(default=0)),
                ('date', models.DateTimeField(auto_now_add=True)),
                ('review', models.PositiveSmallIntegerField(default=0)),
                ('answers_NO', models.PositiveSmallIntegerField(default=0)),
                ('edited', models.BooleanField(default=False)),
                ('author', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'ordering': ['-date'],
            },
        ),
        migrations.CreateModel(
            name='TagListModel',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('tag', models.CharField(max_length=30, unique=True)),
            ],
        ),
        migrations.CreateModel(
            name='AnswerApproved',
            fields=[
                ('question', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, primary_key=True, related_name='answer_approved', serialize=False, to='QA.QuestionModel')),
            ],
        ),
        migrations.CreateModel(
            name='QVote',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('like_or_dislike', models.BooleanField(default=False)),
                ('question', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='QA.QuestionModel')),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
            ],
        ),
        migrations.CreateModel(
            name='QTagModel',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('question', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='QA.QuestionModel')),
                ('tag', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='QA.TagListModel')),
            ],
        ),
        migrations.CreateModel(
            name='AVote',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('like_or_dislike', models.BooleanField(default=False)),
                ('answer', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='QA.AnswerModel')),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
            ],
        ),
        migrations.AddField(
            model_name='answermodel',
            name='question',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='question', to='QA.QuestionModel'),
        ),
        migrations.AddConstraint(
            model_name='qvote',
            constraint=models.UniqueConstraint(fields=('question', 'user'), name='qvote'),
        ),
        migrations.AddConstraint(
            model_name='qtagmodel',
            constraint=models.UniqueConstraint(fields=('question', 'tag'), name='qtag'),
        ),
        migrations.AddConstraint(
            model_name='avote',
            constraint=models.UniqueConstraint(fields=('answer', 'user'), name='avote'),
        ),
        migrations.AddConstraint(
            model_name='answermodel',
            constraint=models.UniqueConstraint(fields=('question', 'author'), name='answer'),
        ),
        migrations.AddField(
            model_name='answerapproved',
            name='answer',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='QA.AnswerModel'),
        ),
    ]
