# Copyright (C) 2026 Collabora Limited
#
# Author: Igor Ponomarev <igor.ponomarev@collabora.com>
#
# SPDX-License-Identifier: GPL-2.0-or-later

# Generated by Django 4.2.23 on 2026-02-27 12:58

import django.core.validators
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):
    replaces = [
        ("lava_results_app", "0001_initial"),
        ("lava_results_app", "0002_auto_20150825_1926"),
        ("lava_results_app", "0003_auto_20150908_1522"),
        ("lava_results_app", "0004_auto_20150925_0002"),
        ("lava_results_app", "0005_auto_20151124_1419"),
        ("lava_results_app", "0006_auto_20160111_1318"),
        ("lava_results_app", "0007_auto_20160225_1256"),
        ("lava_results_app", "0008_auto_20160405_1543"),
        ("lava_results_app", "0009_query_limit"),
        ("lava_results_app", "0010_auto_20160504_0814"),
        ("lava_results_app", "0011_namedtestattribute"),
        ("lava_results_app", "0012_namedtestattribute_metadata"),
        ("lava_results_app", "0013_buglinks"),
        ("lava_results_app", "0014_xaxis_maxlength_increase"),
        ("lava_results_app", "0015_add_test_case_result_index"),
        ("lava_results_app", "0016_add_testcase_start_end_tc"),
        ("lava_results_app", "0017_testdata_onetoone_field"),
        ("lava_results_app", "0018_drop_buglink"),
    ]

    initial = True

    dependencies = [
        ("contenttypes", "0001_initial"),
        ("contenttypes", "0002_remove_content_type_name"),
        ("lava_scheduler_app", "0005_auto_devicedictionarytable_pipelinestore"),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ("auth", "0001_initial"),
    ]

    operations = [
        migrations.CreateModel(
            name="MetaType",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("name", models.CharField(max_length=256)),
                (
                    "metatype",
                    models.PositiveIntegerField(
                        choices=[
                            (0, "deploy"),
                            (1, "boot"),
                            (2, "test"),
                            (3, "diagnostic"),
                            (4, "finalize"),
                            (5, "unknown type"),
                        ],
                        help_text="metadata action type",
                        verbose_name="Type",
                    ),
                ),
            ],
        ),
        migrations.CreateModel(
            name="TestData",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "testjob",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="lava_scheduler_app.testjob",
                    ),
                ),
            ],
        ),
        migrations.CreateModel(
            name="TestSuite",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "name",
                    models.CharField(
                        blank=True,
                        default=None,
                        max_length=200,
                        null=True,
                        verbose_name="Suite name",
                    ),
                ),
                (
                    "job",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="lava_scheduler_app.testjob",
                    ),
                ),
            ],
        ),
        migrations.CreateModel(
            name="TestSet",
            fields=[
                ("id", models.AutoField(primary_key=True, serialize=False)),
                (
                    "name",
                    models.CharField(
                        blank=True,
                        default=None,
                        max_length=200,
                        null=True,
                        verbose_name="Suite name",
                    ),
                ),
                (
                    "suite",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="test_sets",
                        to="lava_results_app.testsuite",
                    ),
                ),
            ],
        ),
        migrations.CreateModel(
            name="TestCase",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "name",
                    models.TextField(
                        blank=True,
                        help_text="Maximum length: 100 characters",
                        verbose_name="Name",
                    ),
                ),
                (
                    "units",
                    models.TextField(
                        blank=True,
                        help_text="Units in which measurement value should be\n                     interpreted, for example <q>ms</q>, <q>MB/s</q> etc.\n                     There is no semantic meaning inferred from the value of\n                     this field, free form text is allowed. <br/>Maximum length: 100 characters",
                        verbose_name="Units",
                    ),
                ),
                (
                    "result",
                    models.PositiveSmallIntegerField(
                        choices=[
                            (0, "Test passed"),
                            (1, "Test failed"),
                            (2, "Test skipped"),
                            (3, "Unknown outcome"),
                        ],
                        db_index=True,
                        help_text="Result classification to pass/fail group",
                        verbose_name="Result",
                    ),
                ),
                (
                    "measurement",
                    models.DecimalField(
                        blank=True,
                        decimal_places=10,
                        help_text="Arbitrary value that was measured as a part of this test.",
                        max_digits=30,
                        null=True,
                        verbose_name="Measurement",
                    ),
                ),
                (
                    "metadata",
                    models.CharField(
                        blank=True,
                        help_text="Metadata collected by the pipeline action, stored as YAML.",
                        max_length=4096,
                        null=True,
                        verbose_name="Action meta data as a YAML string",
                    ),
                ),
                ("logged", models.DateTimeField(auto_now=True)),
                (
                    "suite",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="lava_results_app.testsuite",
                    ),
                ),
                (
                    "test_set",
                    models.ForeignKey(
                        blank=True,
                        default=None,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="test_cases",
                        to="lava_results_app.testset",
                    ),
                ),
                (
                    "end_log_line",
                    models.PositiveIntegerField(blank=True, editable=False, null=True),
                ),
                (
                    "start_log_line",
                    models.PositiveIntegerField(blank=True, editable=False, null=True),
                ),
            ],
        ),
        migrations.CreateModel(
            name="ActionData",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("action_name", models.CharField(max_length=100)),
                ("action_level", models.CharField(max_length=32)),
                ("action_summary", models.CharField(max_length=100)),
                ("action_description", models.CharField(max_length=200)),
                ("yaml_line", models.PositiveIntegerField(blank=True, null=True)),
                (
                    "description_line",
                    models.PositiveIntegerField(blank=True, null=True),
                ),
                ("log_section", models.CharField(blank=True, max_length=50, null=True)),
                (
                    "duration",
                    models.DecimalField(
                        blank=True, decimal_places=2, max_digits=8, null=True
                    ),
                ),
                ("timeout", models.PositiveIntegerField(blank=True, null=True)),
                ("count", models.PositiveIntegerField(blank=True, null=True)),
                ("max_retries", models.PositiveIntegerField(blank=True, null=True)),
                (
                    "meta_type",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="actionlevels",
                        to="lava_results_app.metatype",
                    ),
                ),
                (
                    "testcase",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="actionlevels",
                        to="lava_results_app.testcase",
                    ),
                ),
                (
                    "testdata",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="actionlevels",
                        to="lava_results_app.testdata",
                    ),
                ),
            ],
        ),
        migrations.CreateModel(
            name="QueryGroup",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("name", models.SlugField(max_length=1024, unique=True)),
            ],
        ),
        migrations.CreateModel(
            name="Query",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "name",
                    models.SlugField(
                        help_text="The <b>name</b> of a query is used to refer to it in the web UI.",
                        max_length=1024,
                    ),
                ),
                ("description", models.TextField(blank=True, null=True)),
                (
                    "is_published",
                    models.BooleanField(default=False, verbose_name="Published"),
                ),
                (
                    "group_by_attribute",
                    models.CharField(
                        blank=True,
                        max_length=20,
                        null=True,
                        verbose_name="group by attribute",
                    ),
                ),
                (
                    "target_goal",
                    models.DecimalField(
                        blank=True,
                        decimal_places=5,
                        max_digits=10,
                        null=True,
                        verbose_name="Target goal",
                    ),
                ),
                (
                    "content_type",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="contenttypes.contenttype",
                        verbose_name="Query object set",
                    ),
                ),
                (
                    "group",
                    models.ForeignKey(
                        blank=True,
                        default=None,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        to="auth.group",
                    ),
                ),
                (
                    "owner",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "query_group",
                    models.ForeignKey(
                        blank=True,
                        default=None,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        to="lava_results_app.querygroup",
                    ),
                ),
                (
                    "is_changed",
                    models.BooleanField(
                        default=False, verbose_name="Conditions have changed"
                    ),
                ),
                (
                    "is_live",
                    models.BooleanField(default=False, verbose_name="Live query"),
                ),
                (
                    "is_updating",
                    models.BooleanField(
                        default=False,
                        editable=False,
                        verbose_name="Query is currently updating",
                    ),
                ),
                ("last_updated", models.DateTimeField(blank=True, null=True)),
                (
                    "is_archived",
                    models.BooleanField(default=False, verbose_name="Archived"),
                ),
                (
                    "limit",
                    models.PositiveIntegerField(
                        default=200,
                        validators=[django.core.validators.MinValueValidator(20)],
                        verbose_name="Results limit",
                    ),
                ),
            ],
            options={
                "unique_together": {("owner", "name")},
                "verbose_name": "query",
                "verbose_name_plural": "queries",
            },
        ),
        migrations.CreateModel(
            name="Chart",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("name", models.SlugField(max_length=1024, unique=True)),
                ("description", models.TextField(blank=True, null=True)),
                (
                    "is_published",
                    models.BooleanField(default=False, verbose_name="Published"),
                ),
            ],
        ),
        migrations.CreateModel(
            name="ChartGroup",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("name", models.SlugField(max_length=1024, unique=True)),
            ],
        ),
        migrations.CreateModel(
            name="ChartQuery",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "chart_type",
                    models.CharField(
                        choices=[
                            ("pass/fail", "Pass/Fail"),
                            ("measurement", "Measurement"),
                            ("attributes", "Attributes"),
                        ],
                        default="pass/fail",
                        max_length=20,
                        verbose_name="Chart type",
                    ),
                ),
                (
                    "target_goal",
                    models.DecimalField(
                        blank=True,
                        decimal_places=5,
                        max_digits=10,
                        null=True,
                        verbose_name="Target goal",
                    ),
                ),
                (
                    "chart_height",
                    models.PositiveIntegerField(
                        default=300,
                        validators=[
                            django.core.validators.MinValueValidator(200),
                            django.core.validators.MaxValueValidator(400),
                        ],
                        verbose_name="Chart height",
                    ),
                ),
                (
                    "is_percentage",
                    models.BooleanField(default=False, verbose_name="Percentage"),
                ),
                (
                    "chart_visibility",
                    models.CharField(
                        choices=[
                            ("chart", "Chart only"),
                            ("table", "Result table only"),
                            ("both", "Both"),
                        ],
                        default="chart",
                        max_length=20,
                        verbose_name="Chart visibility",
                    ),
                ),
                (
                    "xaxis_attribute",
                    models.CharField(
                        blank=True,
                        max_length=100,
                        null=True,
                        verbose_name="X-axis attribute",
                    ),
                ),
                (
                    "representation",
                    models.CharField(
                        choices=[("lines", "Lines"), ("bars", "Bars")],
                        default="lines",
                        max_length=20,
                        verbose_name="Representation",
                    ),
                ),
                (
                    "relative_index",
                    models.PositiveIntegerField(
                        default=0, verbose_name="Order in the chart"
                    ),
                ),
                (
                    "attributes",
                    models.CharField(
                        blank=True,
                        max_length=200,
                        null=True,
                        verbose_name="Chart attributes",
                    ),
                ),
                (
                    "chart",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="lava_results_app.chart",
                    ),
                ),
                (
                    "query",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="lava_results_app.query",
                    ),
                ),
            ],
            options={
                "ordering": ["relative_index"],
            },
        ),
        migrations.CreateModel(
            name="ChartQueryUser",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("start_date", models.CharField(max_length=20)),
                (
                    "is_legend_visible",
                    models.BooleanField(default=True, verbose_name="Toggle legend"),
                ),
                (
                    "is_delta",
                    models.BooleanField(default=False, verbose_name="Delta reporting"),
                ),
                (
                    "chart_query",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="lava_results_app.chartquery",
                    ),
                ),
                (
                    "user",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "unique_together": {("chart_query", "user")},
            },
        ),
        migrations.AddField(
            model_name="chart",
            name="chart_group",
            field=models.ForeignKey(
                default=None,
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                to="lava_results_app.chartgroup",
            ),
        ),
        migrations.AddField(
            model_name="chart",
            name="group",
            field=models.ForeignKey(
                default=None,
                null=True,
                on_delete=django.db.models.deletion.SET_NULL,
                to="auth.group",
            ),
        ),
        migrations.AddField(
            model_name="chart",
            name="owner",
            field=models.ForeignKey(
                default=None,
                on_delete=django.db.models.deletion.CASCADE,
                to=settings.AUTH_USER_MODEL,
            ),
        ),
        migrations.AddField(
            model_name="chart",
            name="queries",
            field=models.ManyToManyField(
                blank=True,
                through="lava_results_app.ChartQuery",
                to="lava_results_app.query",
            ),
        ),
        migrations.CreateModel(
            name="QueryCondition",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("field", models.CharField(max_length=50, verbose_name="Field name")),
                (
                    "operator",
                    models.CharField(
                        choices=[
                            ("exact", "Exact match"),
                            ("iexact", "Case-insensitive match"),
                            ("ne", "Not equal to"),
                            ("icontains", "Contains"),
                            ("gt", "Greater than"),
                            ("lt", "Less than"),
                        ],
                        default="exact",
                        max_length=20,
                        verbose_name="Operator",
                    ),
                ),
                ("value", models.CharField(max_length=40, verbose_name="Field value")),
                (
                    "query",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="lava_results_app.query",
                    ),
                ),
                (
                    "table",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="contenttypes.contenttype",
                        verbose_name="Condition model",
                    ),
                ),
            ],
        ),
        migrations.CreateModel(
            name="QueryOmitResult",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("object_id", models.PositiveIntegerField()),
                (
                    "content_type",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="contenttypes.contenttype",
                    ),
                ),
                (
                    "query",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="lava_results_app.query",
                    ),
                ),
            ],
            options={
                "unique_together": {("object_id", "query", "content_type")},
            },
        ),
        migrations.CreateModel(
            name="NamedTestAttribute",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("name", models.TextField()),
                ("value", models.TextField()),
                ("object_id", models.PositiveIntegerField()),
                (
                    "content_type",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="contenttypes.contenttype",
                    ),
                ),
            ],
            options={
                "unique_together": {("object_id", "name", "content_type")},
                "verbose_name": "metadata",
            },
        ),
        migrations.CreateModel(
            name="BugLink",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("url", models.URLField(max_length=1024, verbose_name="Bug Link URL")),
                ("object_id", models.PositiveIntegerField()),
                (
                    "content_type",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="contenttypes.contenttype",
                    ),
                ),
            ],
            options={
                "unique_together": {("object_id", "url", "content_type")},
            },
        ),
        migrations.SeparateDatabaseAndState(
            state_operations=[
                migrations.AlterField(
                    model_name="testdata",
                    name="testjob",
                    field=models.OneToOneField(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="lava_scheduler_app.testjob",
                    ),
                ),
            ],
        ),
        migrations.DeleteModel(
            name="BugLink",
        ),
    ]
