# Generated by Django 2.1 on 2018-10-23 15:38

import base.fields
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('targets', '0001_initial'),
    ]

    operations = [
        migrations.CreateModel(
            name='Action',
            fields=[
                ('id', models.CharField(default=base.fields.generate_id, editable=False, max_length=22, primary_key=True, serialize=False)),
                ('created_at', models.DateTimeField(auto_now_add=True, db_index=True)),
                ('updated_at', models.DateTimeField(auto_now=True, db_index=True)),
                ('description', models.TextField()),
                ('agent', base.fields.ValidatedJSONField(blank=True, null=True, schema={'additionalProperties': False, 'properties': {'email': {'type': 'string'}, 'full_name': {'type': 'string'}, 'type': {'type': 'string'}, 'username': {'type': 'string'}}, 'required': ['username', 'type'], 'type': 'object'})),
            ],
            options={
                'ordering': ['-created_at'],
            },
        ),
        migrations.CreateModel(
            name='ActionType',
            fields=[
                ('id', models.SlugField(max_length=255, primary_key=True, serialize=False)),
                ('description', models.CharField(blank=True, max_length=255, null=True)),
            ],
            options={
                'ordering': ['id'],
            },
        ),
        migrations.CreateModel(
            name='Alert',
            fields=[
                ('id', models.CharField(default=base.fields.generate_id, editable=False, max_length=22, primary_key=True, serialize=False)),
                ('created_at', models.DateTimeField(auto_now_add=True, db_index=True)),
                ('updated_at', models.DateTimeField(auto_now=True, db_index=True)),
                ('level', models.CharField(choices=[('green', 'green alert'), ('yellow', 'yellow alert'), ('orange', 'orange alert'), ('red', 'red alert')], db_index=True, max_length=127)),
                ('escalation_level', models.IntegerField(default=0)),
                ('state', models.CharField(choices=[('active', 'active, unattended'), ('attended', 'active, attended'), ('resolved', 'resolved and inactive')], db_index=True, max_length=127)),
                ('latest_value', models.DecimalField(decimal_places=8, max_digits=16)),
                ('timeseries', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='alerts', to='targets.Timeseries')),
            ],
            options={
                'ordering': ['-created_at'],
            },
        ),
        migrations.CreateModel(
            name='AlertEscalationPolicy',
            fields=[
                ('id', models.CharField(default=base.fields.generate_id, editable=False, max_length=22, primary_key=True, serialize=False)),
                ('after', models.DecimalField(blank=True, decimal_places=8, max_digits=16, null=True)),
                ('every', models.DecimalField(blank=True, decimal_places=8, max_digits=16, null=True)),
                ('min_level', models.CharField(choices=[('green', 'green alert'), ('yellow', 'yellow alert'), ('orange', 'orange alert'), ('red', 'red alert')], db_index=True, max_length=127)),
                ('timeseries', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='escalation_policy', to='targets.Timeseries')),
            ],
            options={
                'verbose_name_plural': 'alert escalation policies',
                'ordering': ['id'],
            },
        ),
        migrations.CreateModel(
            name='AlertType',
            fields=[
                ('id', models.SlugField(max_length=255, primary_key=True, serialize=False)),
                ('description', models.CharField(blank=True, max_length=255, null=True)),
            ],
            options={
                'ordering': ['id'],
            },
        ),
        migrations.AddField(
            model_name='alert',
            name='type',
            field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='+', to='alerts.AlertType'),
        ),
        migrations.AddField(
            model_name='action',
            name='alert',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='actions', to='alerts.Alert'),
        ),
        migrations.AddField(
            model_name='action',
            name='type',
            field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='+', to='alerts.ActionType'),
        ),
    ]
