# Generated by Django 4.2.3 on 2023-07-12 12:13

import django.core.serializers.json
from django.db import migrations, models
import django.db.models.deletion
import scanpipe.models
import uuid


class Migration(migrations.Migration):
    dependencies = [
        ("scanpipe", "0040_discovereddependency_affected_by_vulnerabilities"),
    ]

    operations = [
        migrations.CreateModel(
            name="ProjectMessage",
            fields=[
                (
                    "uuid",
                    models.UUIDField(
                        db_index=True,
                        default=uuid.uuid4,
                        editable=False,
                        primary_key=True,
                        serialize=False,
                        verbose_name="UUID",
                    ),
                ),
                (
                    "severity",
                    models.CharField(
                        choices=[
                            ("info", "Info"),
                            ("warning", "Warning"),
                            ("error", "Error"),
                        ],
                        editable=False,
                        help_text="Severity level of the message.",
                        max_length=10,
                    ),
                ),
                ("description", models.TextField(blank=True, help_text="Description.")),
                (
                    "model",
                    models.CharField(
                        help_text="Name of the model class.", max_length=100
                    ),
                ),
                (
                    "details",
                    models.JSONField(
                        blank=True,
                        default=dict,
                        encoder=django.core.serializers.json.DjangoJSONEncoder,
                        help_text="Data that caused the error.",
                    ),
                ),
                (
                    "traceback",
                    models.TextField(blank=True, help_text="Exception traceback."),
                ),
                ("created_date", models.DateTimeField(auto_now_add=True)),
                (
                    "project",
                    models.ForeignKey(
                        editable=False,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="%(class)ss",
                        to="scanpipe.project",
                    ),
                ),
            ],
            options={
                "ordering": ["created_date"],
                "indexes": [
                    models.Index(
                        fields=["severity"], name="scanpipe_pr_severit_9e1b35_idx"
                    ),
                    models.Index(fields=["model"], name="scanpipe_pr_model_013dd4_idx"),
                ],
            },
            bases=(scanpipe.models.UpdateMixin, models.Model),
        ),
    ]
