# Generated by Django 2.0.4 on 2018-04-10 15:22

import django.core.validators
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone
import model_utils.fields
import re


class Migration(migrations.Migration):

    initial = True

    dependencies = [
    ]

    operations = [
        migrations.CreateModel(
            name='CrossReference',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now, editable=False, verbose_name='created')),
                ('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now, editable=False, verbose_name='modified')),
                ('source', models.CharField(db_index=True, max_length=25)),
                ('source_value', models.CharField(max_length=255)),
            ],
            options={
                'verbose_name_plural': 'Cross References',
                'verbose_name': 'Cross Reference',
            },
        ),
        migrations.CreateModel(
            name='Ontology',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now, editable=False, verbose_name='created')),
                ('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now, editable=False, verbose_name='modified')),
                ('type', models.PositiveSmallIntegerField(choices=[(1, 'HP'), (2, 'MONDO'), (3, 'NCIT')])),
                ('label', models.CharField(max_length=100)),
                ('active', models.BooleanField(default=True)),
            ],
            options={
                'verbose_name_plural': 'Ontology',
                'verbose_name': 'Ontology',
            },
        ),
        migrations.CreateModel(
            name='Relationship',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now, editable=False, verbose_name='created')),
                ('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now, editable=False, verbose_name='modified')),
            ],
            options={
                'verbose_name_plural': 'Relationships',
                'verbose_name': 'Relationship',
            },
        ),
        migrations.CreateModel(
            name='RelationshipType',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now, editable=False, verbose_name='created')),
                ('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now, editable=False, verbose_name='modified')),
                ('label', models.CharField(max_length=50, unique=True)),
                ('description', models.CharField(blank=True, max_length=255)),
                ('slug', models.SlugField(unique=True)),
                ('active', models.BooleanField(default=True)),
            ],
            options={
                'verbose_name_plural': 'Relationship Types',
                'verbose_name': 'Relationship Types',
            },
        ),
        migrations.CreateModel(
            name='Synonym',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now, editable=False, verbose_name='created')),
                ('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now, editable=False, verbose_name='modified')),
                ('description', models.TextField(blank=True)),
                ('scope', models.PositiveSmallIntegerField(blank=True, choices=[(1, 'EXACT'), (2, 'BROAD'), (3, 'NARROW'), (4, 'RELATED'), (5, 'ABBREVATION')], null=True)),
            ],
            options={
                'verbose_name_plural': 'Synonyms',
                'verbose_name': 'Synonym',
            },
        ),
        migrations.CreateModel(
            name='Term',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('identifier', models.CharField(db_index=True, max_length=25)),
                ('label', models.CharField(db_index=True, max_length=255)),
                ('description', models.TextField(blank=True)),
                ('alternate_ids', models.CharField(blank=True, max_length=2500, validators=[django.core.validators.RegexValidator(re.compile('^\\d+(?:\\,\\d+)*\\Z'), code='invalid', message='Enter only digits separated by commas.')])),
                ('created_by', models.CharField(blank=True, max_length=50)),
                ('created', models.CharField(blank=True, max_length=25)),
                ('modified', models.DateTimeField(auto_now=True)),
                ('ontology', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='phenotype_ontologies.Ontology')),
            ],
            options={
                'verbose_name_plural': 'Terms',
                'verbose_name': 'Term',
            },
        ),
        migrations.AddField(
            model_name='synonym',
            name='term',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='synonyms', to='phenotype_ontologies.Term'),
        ),
        migrations.AddField(
            model_name='relationship',
            name='related_term',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='relationships_related', to='phenotype_ontologies.Term'),
        ),
        migrations.AddField(
            model_name='relationship',
            name='term',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='relationships', to='phenotype_ontologies.Term'),
        ),
        migrations.AddField(
            model_name='relationship',
            name='type',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='relationships', to='phenotype_ontologies.RelationshipType'),
        ),
        migrations.AddField(
            model_name='crossreference',
            name='term',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='xrefs', to='phenotype_ontologies.Term'),
        ),
        migrations.AlterIndexTogether(
            name='term',
            index_together={('ontology', 'identifier')},
        ),
    ]
