# Generated by Django 3.0.4 on 2020-04-08 10:09

import uuid

import django.contrib.postgres.fields.jsonb
import django.db.models.deletion
import simple_history.models
from django.db import migrations, models


class Migration(migrations.Migration):

    initial = True

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

    operations = [
        migrations.CreateModel(
            name='Topic',
            fields=[
                ('slug', models.CharField(max_length=32, primary_key=True, serialize=False, unique=True)),
                ('name', models.CharField(max_length=64)),
                ('icon', models.URLField(null=True)),
                ('description', models.TextField(null=True)),
                ('color', models.CharField(max_length=16)),
                ('style', models.CharField(default='', max_length=256, null=True)),
                ('last_activity_at', models.DateTimeField(auto_now_add=True)),
                ('is_visible', models.BooleanField(default=True)),
                ('is_visible_on_main_page', models.BooleanField(default=True)),
            ],
            options={
                'db_table': 'topics',
                'ordering': ['-last_activity_at'],
            },
        ),
        migrations.CreateModel(
            name='Post',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('slug', models.CharField(db_index=True, max_length=128, unique=True)),
                ('type', models.CharField(choices=[('post', 'Текст'), ('intro', '#intro'), ('link', 'Ссылка'), ('question', 'Вопрос'), ('pain', 'Расскажи где болит'), ('project', 'Проект'), ('referral', 'Рефералка'), ('battle', 'Батл')], db_index=True, default='post', max_length=32)),
                ('label', django.contrib.postgres.fields.jsonb.JSONField(null=True)),
                ('title', models.TextField()),
                ('text', models.TextField()),
                ('html', models.TextField(null=True)),
                ('url', models.URLField(null=True)),
                ('image', models.URLField(null=True)),
                ('metadata', django.contrib.postgres.fields.jsonb.JSONField(null=True)),
                ('created_at', models.DateTimeField(auto_now_add=True, db_index=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('last_activity_at', models.DateTimeField(auto_now_add=True, db_index=True)),
                ('comment_count', models.IntegerField(default=0)),
                ('view_count', models.IntegerField(default=0)),
                ('upvotes', models.IntegerField(db_index=True, default=0)),
                ('is_visible', models.BooleanField(default=True)),
                ('is_visible_on_main_page', models.BooleanField(default=True)),
                ('is_commentable', models.BooleanField(default=True)),
                ('is_approved_by_moderator', models.BooleanField(default=False)),
                ('is_public', models.BooleanField(default=False)),
                ('is_pinned_until', models.DateTimeField(null=True)),
                ('author', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='posts', to='users.User')),
                ('topic', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='posts', to='posts.Topic')),
            ],
            options={
                'db_table': 'posts',
                'ordering': ['-created_at'],
            },
        ),
        migrations.CreateModel(
            name='HistoricalPost',
            fields=[
                ('id', models.UUIDField(db_index=True, default=uuid.uuid4, editable=False)),
                ('slug', models.CharField(db_index=True, max_length=128)),
                ('type', models.CharField(choices=[('post', 'Текст'), ('intro', '#intro'), ('link', 'Ссылка'), ('question', 'Вопрос'), ('pain', 'Расскажи где болит'), ('project', 'Проект'), ('referral', 'Рефералка'), ('battle', 'Батл')], db_index=True, default='post', max_length=32)),
                ('label', django.contrib.postgres.fields.jsonb.JSONField(null=True)),
                ('title', models.TextField()),
                ('text', models.TextField()),
                ('url', models.URLField(null=True)),
                ('image', models.URLField(null=True)),
                ('metadata', django.contrib.postgres.fields.jsonb.JSONField(null=True)),
                ('is_visible', models.BooleanField(default=True)),
                ('is_visible_on_main_page', models.BooleanField(default=True)),
                ('is_commentable', models.BooleanField(default=True)),
                ('is_approved_by_moderator', models.BooleanField(default=False)),
                ('is_public', models.BooleanField(default=False)),
                ('is_pinned_until', models.DateTimeField(null=True)),
                ('history_id', models.AutoField(primary_key=True, serialize=False)),
                ('history_date', models.DateTimeField()),
                ('history_change_reason', models.CharField(max_length=100, null=True)),
                ('history_type', models.CharField(choices=[('+', 'Created'), ('~', 'Changed'), ('-', 'Deleted')], max_length=1)),
                ('author', models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='users.User')),
                ('history_user', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='users.User')),
                ('topic', models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='posts.Topic')),
            ],
            options={
                'verbose_name': 'historical post',
                'db_table': 'posts_history',
                'ordering': ('-history_date', '-history_id'),
                'get_latest_by': 'history_date',
            },
            bases=(simple_history.models.HistoricalChanges, models.Model),
        ),
        migrations.CreateModel(
            name='PostVote',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('post', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='votes', to='posts.Post')),
                ('user', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='post_votes', to='users.User')),
            ],
            options={
                'db_table': 'post_votes',
                'unique_together': {('user', 'post')},
            },
        ),
    ]
