# Generated by Django 4.1.7 on 2023-05-21 21:17

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


class Migration(migrations.Migration):
    dependencies = [
        ("diop", "0010_machine_agent"),
    ]

    operations = [
        migrations.CreateModel(
            name="Task",
            fields=[
                (
                    "name",
                    models.CharField(
                        max_length=128,
                        primary_key=True,
                        serialize=False,
                        verbose_name="Task Name",
                    ),
                ),
                ("t_start", models.DateTimeField(verbose_name="Start Time")),
                (
                    "t_end",
                    models.DateTimeField(
                        blank=True,
                        help_text="Empty if task is still running or did not succeed.",
                        null=True,
                        verbose_name="End Time",
                    ),
                ),
                (
                    "unfinished",
                    models.SmallIntegerField(
                        default=0,
                        help_text="Counter on previous unfinished runs when next one tries to start.",
                    ),
                ),
                (
                    "failed",
                    models.SmallIntegerField(
                        default=0, help_text="Counter on previously failed attempts."
                    ),
                ),
                (
                    "description",
                    models.CharField(blank=True, max_length=128, null=True),
                ),
            ],
        ),
        migrations.CreateModel(
            name="Issue",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "severity",
                    models.SmallIntegerField(
                        default=0, help_text="Higher means more critical."
                    ),
                ),
                (
                    "timestamp",
                    models.DateTimeField(help_text="Time the issue occurred."),
                ),
                (
                    "resolved",
                    models.BooleanField(
                        help_text="Flag indicating the issue is resolved."
                    ),
                ),
                ("description", models.CharField(max_length=512)),
                (
                    "task",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        to="diop.task",
                        verbose_name="Task causing the issue (if applicable).",
                    ),
                ),
                (
                    "user",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        to="diop.user",
                        verbose_name="User related to the issue (if applicable).",
                    ),
                ),
            ],
        ),
    ]
