# Generated by Django 2.2.24 on 2021-12-06 07:16

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 = [
        ('core', '0018_delete_phrase'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ('elastic', '0015_breakup_characters'),
    ]

    operations = [
        migrations.CreateModel(
            name='Annotator',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('description', models.CharField(max_length=100)),
                ('query', models.TextField(default='{"query": {"match_all": {}}}')),
                ('fields', models.TextField(default='[]')),
                ('bulk_size', models.IntegerField(default=100, help_text='How many documents should be sent into Elasticsearch in a single batch for update.', validators=[django.core.validators.MinValueValidator(0), django.core.validators.MaxValueValidator(500)])),
                ('es_timeout', models.IntegerField(default=10, help_text='How many seconds should be allowed for the the update request to Elasticsearch.', validators=[django.core.validators.MinValueValidator(0), django.core.validators.MaxValueValidator(100)])),
                ('annotation_type', models.CharField(choices=[('binary', 'binary'), ('multilabel', 'multilabel'), ('entity', 'entity')], help_text='Which type of annotation does the user wish to perform', max_length=100)),
                ('created_at', models.DateTimeField(auto_now_add=True, null=True)),
                ('modified_at', models.DateTimeField(auto_now=True, null=True)),
                ('completed_at', models.DateTimeField(default=None, null=True)),
                ('total', models.IntegerField(default=0, help_text='How many documents are going to be annotated.')),
                ('validated', models.IntegerField(default=0, help_text='How many documents of the total have been validated.')),
                ('target_field', models.CharField(default='', help_text='Which Elasticsearch document field you use base the annotation on.', max_length=100)),
                ('annotator_users', models.ManyToManyField(default=None, help_text='Who are the users who will be annotating.', related_name='annotators', to=settings.AUTH_USER_MODEL)),
                ('author', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='BinaryAnnotatorConfiguration',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('fact_name', models.CharField(help_text='Sets the value for the fact name for all annotated documents.', max_length=100)),
                ('pos_value', models.CharField(help_text='Sets the name for a fact value for positive documents.', max_length=100)),
                ('neg_value', models.CharField(help_text='Sets the name for a fact value for negative documents.', max_length=100)),
            ],
        ),
        migrations.CreateModel(
            name='Category',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('value', models.CharField(max_length=100, unique=True)),
            ],
        ),
        migrations.CreateModel(
            name='EntityAnnotatorConfiguration',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('fact_name', models.CharField(help_text='Name of the fact which will be added.', max_length=100)),
            ],
        ),
        migrations.CreateModel(
            name='Label',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('value', models.CharField(max_length=100, unique=True)),
            ],
        ),
        migrations.CreateModel(
            name='Labelset',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('category', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='annotator.Category')),
                ('values', models.ManyToManyField(to='annotator.Label')),
            ],
        ),
        migrations.CreateModel(
            name='Record',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('document_id', models.CharField(db_index=True, max_length=100)),
                ('index', models.CharField(max_length=100)),
                ('fact_id', models.TextField(db_index=True, default=None, null=True)),
                ('fact', models.TextField(default='{}')),
                ('annotated_utc', models.DateTimeField(default=None, null=True)),
                ('skipped_utc', models.DateTimeField(default=None, null=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('annotation_job', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='annotator.Annotator')),
                ('user', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL)),
            ],
        ),
        migrations.CreateModel(
            name='MultilabelAnnotatorConfiguration',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('labelset', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='annotator.Labelset')),
            ],
        ),
        migrations.CreateModel(
            name='Comment',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('text', models.TextField()),
                ('document_id', models.CharField(max_length=100)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('annotation_job', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='annotator.Annotator')),
                ('user', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL)),
            ],
        ),
        migrations.AddField(
            model_name='annotator',
            name='binary_configuration',
            field=models.ForeignKey(default=None, help_text='Settings for binary type annotations.', null=True, on_delete=django.db.models.deletion.SET_NULL, to='annotator.BinaryAnnotatorConfiguration'),
        ),
        migrations.AddField(
            model_name='annotator',
            name='entity_configuration',
            field=models.ForeignKey(default=None, help_text='Settings for entity type annotations.', null=True, on_delete=django.db.models.deletion.SET_NULL, to='annotator.EntityAnnotatorConfiguration'),
        ),
        migrations.AddField(
            model_name='annotator',
            name='indices',
            field=models.ManyToManyField(default=[], help_text='Which indices to query from Elasticsearch', to='elastic.Index'),
        ),
        migrations.AddField(
            model_name='annotator',
            name='multilabel_configuration',
            field=models.ForeignKey(default=None, help_text='Settings for multilabel type annotations.', null=True, on_delete=django.db.models.deletion.SET_NULL, to='annotator.MultilabelAnnotatorConfiguration'),
        ),
        migrations.AddField(
            model_name='annotator',
            name='project',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.Project'),
        ),
    ]
