# -*- coding: utf-8 -*-
# Generated by Django 1.11 on 2017-09-25 08:56
from __future__ import unicode_literals

from django.conf import settings
import django.contrib.postgres.fields
import django.contrib.postgres.fields.jsonb
from django.db import migrations, models
import django.db.models.deletion
import uuid
import wapipelines.models


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='Pipeline',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=255)),
                ('uuid', models.UUIDField(default=uuid.uuid4)),
                ('secret', models.CharField(blank=True, default=wapipelines.models.generate_secret, max_length=255)),
                ('planning', django.contrib.postgres.fields.ArrayField(base_field=models.UUIDField(blank=True, null=True), default=[], size=None)),
                ('dot', models.TextField(blank=True, null=True)),
                ('endpoint', models.URLField(blank=True, null=True)),
                ('active', models.BooleanField(default=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
            ],
        ),
        migrations.CreateModel(
            name='PipelineRun',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('uuid', models.UUIDField(default=uuid.uuid4)),
                ('dot', models.TextField(blank=True, null=True)),
                ('expected_outputs', django.contrib.postgres.fields.ArrayField(base_field=models.CharField(max_length=255), size=None)),
                ('payload', django.contrib.postgres.fields.jsonb.JSONField(blank=True, null=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('pipeline', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='wapipelines.Pipeline')),
            ],
            options={
                'ordering': ('-created_at',),
            },
        ),
        migrations.CreateModel(
            name='Result',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('uuid', models.UUIDField(default=uuid.uuid4)),
                ('inputs', django.contrib.postgres.fields.jsonb.JSONField(default=dict)),
                ('outputs', django.contrib.postgres.fields.jsonb.JSONField(default=dict)),
                ('duration', models.DurationField()),
                ('response_code', models.PositiveIntegerField(blank=True, null=True)),
                ('error', models.TextField(blank=True, null=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('pipeline', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='wapipelines.Pipeline')),
                ('run', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='wapipelines.PipelineRun')),
            ],
            options={
                'ordering': ('created_at',),
            },
        ),
        migrations.CreateModel(
            name='Step',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(blank=True, max_length=255, null=True)),
                ('uuid', models.UUIDField(default=uuid.uuid4)),
                ('inputs', django.contrib.postgres.fields.ArrayField(base_field=models.CharField(blank=True, max_length=125), size=None)),
                ('outputs', django.contrib.postgres.fields.ArrayField(base_field=models.CharField(blank=True, max_length=125), size=None)),
                ('url', models.URLField(blank=True, null=True)),
                ('headers', django.contrib.postgres.fields.jsonb.JSONField(default=dict, verbose_name=b'HTTP headers to submit as part of the step')),
                ('timeout', models.PositiveIntegerField(choices=[(50, b'50 milliseconds'), (100, b'100 milliseconds'), (200, b'200 milliseconds'), (3000, b'3 seconds'), (10000, b'10 seconds')], default=100, verbose_name=b'Timeout in milliseconds')),
                ('error', models.TextField(blank=True, null=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('pipeline', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='wapipelines.Pipeline')),
            ],
        ),
        migrations.AddField(
            model_name='result',
            name='step',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='wapipelines.Step'),
        ),
    ]
