# -*- coding: utf-8 -*-
# Generated by Django 1.11.14 on 2018-08-13 17:28
from __future__ import unicode_literals

from django.conf import settings
import django.contrib.postgres.fields.jsonb
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone


class Migration(migrations.Migration):

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ('tantalus', '0060_auto_20180810_1906'),
    ]

    operations = [
        migrations.CreateModel(
            name='Analysis',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=200, unique=True)),
                ('jira_ticket', models.CharField(blank=True, max_length=50, null=True)),
                ('last_updated', models.DateTimeField(default=django.utils.timezone.now, null=True)),
                ('status', models.CharField(default='Unknown', max_length=50)),
                ('args', django.contrib.postgres.fields.jsonb.JSONField(blank=True, null=True)),
                ('input_datasets', models.ManyToManyField(related_name='inputdatasets', to='tantalus.SequenceDataset')),
            ],
        ),
        migrations.CreateModel(
            name='HistoricalAnalysis',
            fields=[
                ('id', models.IntegerField(auto_created=True, blank=True, db_index=True, verbose_name='ID')),
                ('name', models.CharField(db_index=True, max_length=200)),
                ('jira_ticket', models.CharField(blank=True, max_length=50, null=True)),
                ('last_updated', models.DateTimeField(default=django.utils.timezone.now, null=True)),
                ('status', models.CharField(default='Unknown', max_length=50)),
                ('args', django.contrib.postgres.fields.jsonb.JSONField(blank=True, 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)),
                ('history_user', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to=settings.AUTH_USER_MODEL)),
                ('owner', models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'ordering': ('-history_date', '-history_id'),
                'get_latest_by': 'history_date',
                'verbose_name': 'historical analysis',
            },
        ),
        migrations.CreateModel(
            name='HistoricalResultsDataset',
            fields=[
                ('id', models.IntegerField(auto_created=True, blank=True, db_index=True, verbose_name='ID')),
                ('name', models.CharField(db_index=True, max_length=200)),
                ('results_type', models.CharField(max_length=50)),
                ('results_version', models.CharField(max_length=50)),
                ('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)),
                ('analysis', models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='tantalus.Analysis')),
                ('history_user', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to=settings.AUTH_USER_MODEL)),
                ('owner', models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'ordering': ('-history_date', '-history_id'),
                'get_latest_by': 'history_date',
                'verbose_name': 'historical results dataset',
            },
        ),
        migrations.CreateModel(
            name='ResultsDataset',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=200, unique=True)),
                ('results_type', models.CharField(max_length=50)),
                ('results_version', models.CharField(max_length=50)),
                ('analysis', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='tantalus.Analysis')),
                ('file_resources', models.ManyToManyField(to='tantalus.FileResource')),
                ('owner', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL)),
                ('samples', models.ManyToManyField(to='tantalus.Sample')),
            ],
        ),
        migrations.AddField(
            model_name='analysis',
            name='input_results',
            field=models.ManyToManyField(related_name='inputresults', to='tantalus.ResultsDataset'),
        ),
        migrations.AddField(
            model_name='analysis',
            name='logs',
            field=models.ManyToManyField(to='tantalus.FileResource'),
        ),
        migrations.AddField(
            model_name='analysis',
            name='owner',
            field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='historicalsequencedataset',
            name='analysis',
            field=models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='tantalus.Analysis'),
        ),
        migrations.AddField(
            model_name='sequencedataset',
            name='analysis',
            field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='tantalus.Analysis'),
        ),
    ]
