# Generated by Django 3.0.4 on 2020-09-04 22:01

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


class Migration(migrations.Migration):

    dependencies = [
        ('collab_app', '0007_auto_20200827_1919'),
    ]

    operations = [
        migrations.CreateModel(
            name='Project',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('updated', models.DateTimeField(auto_now=True)),
                ('created', models.DateTimeField(auto_now_add=True)),
                ('name', models.TextField()),
                ('key', models.CharField(max_length=32, unique=True)),
                ('url', models.TextField(blank=True, null=True)),
                ('creator', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='collab_app_project_related', to=settings.AUTH_USER_MODEL)),
            ],
            bases=(collab_app.mixins.models.ModelDiffMixin, models.Model),
        ),
        migrations.CreateModel(
            name='Task',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('updated', models.DateTimeField(auto_now=True)),
                ('created', models.DateTimeField(auto_now_add=True)),
                ('comment', models.TextField(blank=True, default='')),
                ('design_edits', models.TextField(blank=True, default='')),
                ('screenshot_url', models.TextField(blank=True, null=True)),
                ('task_number', models.PositiveIntegerField()),
                ('is_resolved', models.BooleanField(default=False)),
                ('target_id', models.TextField(blank=True, default='')),
                ('target_dom_path', models.TextField(blank=True, default='')),
                ('creator', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='created_tasks', to=settings.AUTH_USER_MODEL)),
                ('project', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='tasks', to='collab_app.Project')),
            ],
            bases=(collab_app.mixins.models.ModelDiffMixin, models.Model),
        ),
        migrations.CreateModel(
            name='TaskColumn',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('updated', models.DateTimeField(auto_now=True)),
                ('created', models.DateTimeField(auto_now_add=True)),
                ('name', models.TextField()),
                ('creator', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='collab_app_taskcolumn_related', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'abstract': False,
            },
            bases=(collab_app.mixins.models.ModelDiffMixin, models.Model),
        ),
        migrations.CreateModel(
            name='TaskComment',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('updated', models.DateTimeField(auto_now=True)),
                ('created', models.DateTimeField(auto_now_add=True)),
                ('text', models.TextField()),
                ('creator', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='created_task_comments', to=settings.AUTH_USER_MODEL)),
                ('task', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='task_comments', to='collab_app.Task')),
            ],
            options={
                'abstract': False,
            },
            bases=(collab_app.mixins.models.ModelDiffMixin, models.Model),
        ),
        migrations.CreateModel(
            name='TaskMetadata',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('updated', models.DateTimeField(auto_now=True)),
                ('created', models.DateTimeField(auto_now_add=True)),
                ('task_logged_at', models.TextField(default='')),
                ('operating_system', models.TextField(default='')),
                ('browser', models.TextField(default='')),
                ('selector', models.TextField(default='')),
                ('resolution', models.TextField(default='')),
                ('browser_window', models.TextField(default='')),
                ('color_depth', models.TextField(default='')),
                ('creator', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='collab_app_taskmetadata_related', to=settings.AUTH_USER_MODEL)),
                ('task', models.OneToOneField(on_delete=django.db.models.deletion.PROTECT, related_name='task_metadata', to='collab_app.Task')),
            ],
            options={
                'abstract': False,
            },
            bases=(collab_app.mixins.models.ModelDiffMixin, models.Model),
        ),
        migrations.RemoveField(
            model_name='thread',
            name='creator',
        ),
        migrations.RemoveField(
            model_name='thread',
            name='organization',
        ),
        migrations.RemoveField(
            model_name='organization',
            name='key',
        ),
        migrations.AlterField(
            model_name='invite',
            name='inviter',
            field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='invites_sent', to=settings.AUTH_USER_MODEL),
        ),
        migrations.AlterField(
            model_name='invite',
            name='organization',
            field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='invites', to='collab_app.Organization'),
        ),
        migrations.AlterField(
            model_name='membership',
            name='organization',
            field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='memberships', to='collab_app.Organization'),
        ),
        migrations.AlterField(
            model_name='membership',
            name='user',
            field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='memberships', to=settings.AUTH_USER_MODEL),
        ),
        migrations.DeleteModel(
            name='Comment',
        ),
        migrations.DeleteModel(
            name='Thread',
        ),
        migrations.AddField(
            model_name='task',
            name='task_column',
            field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='tasks', to='collab_app.TaskColumn'),
        ),
        migrations.AddField(
            model_name='project',
            name='organization',
            field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='projects', to='collab_app.Organization'),
        ),
        migrations.AddConstraint(
            model_name='task',
            constraint=models.UniqueConstraint(fields=('task_number', 'project'), name='unique_tasknumber_project'),
        ),
        migrations.AddConstraint(
            model_name='task',
            constraint=models.CheckConstraint(check=models.Q(models.Q(_negated=True, comment=''), models.Q(_negated=True, design_edits=''), _connector='OR'), name='collab_app_task_comment_or_design_edits'),
        ),
        migrations.AddConstraint(
            model_name='task',
            constraint=models.CheckConstraint(check=models.Q(models.Q(_negated=True, target_id=''), models.Q(_negated=True, target_dom_path=''), _connector='OR'), name='collab_app_task_target_id_or_dom_path'),
        ),
        migrations.AddConstraint(
            model_name='project',
            constraint=models.UniqueConstraint(fields=('organization', 'name'), name='unique_project_org'),
        ),
    ]
