# Generated by Django 5.2.7 on 2026-02-20 12:02

import django.db.models.deletion
import uuid
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):
    dependencies = [
        ("contenttypes", "0002_remove_content_type_name"),
        ("epdb", "0016_remove_enviformer_model_status_and_more"),
    ]

    operations = [
        migrations.CreateModel(
            name="AdditionalInformation",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                ("uuid", models.UUIDField(default=uuid.uuid4, editable=False, unique=True)),
                ("url", models.TextField(null=True, unique=True, verbose_name="URL")),
                ("kv", models.JSONField(blank=True, default=dict, null=True)),
                ("type", models.TextField(verbose_name="Additional Information Type")),
                ("data", models.JSONField(blank=True, default=dict, null=True)),
                ("object_id", models.PositiveBigIntegerField(blank=True, null=True)),
                (
                    "content_type",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        to="contenttypes.contenttype",
                    ),
                ),
                (
                    "package",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to=settings.EPDB_PACKAGE_MODEL,
                        verbose_name="Package",
                    ),
                ),
                (
                    "scenario",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="scenario_additional_information",
                        to="epdb.scenario",
                    ),
                ),
            ],
            options={
                "indexes": [
                    models.Index(fields=["type"], name="epdb_additi_type_394349_idx"),
                    models.Index(
                        fields=["scenario", "type"], name="epdb_additi_scenari_a59edf_idx"
                    ),
                    models.Index(
                        fields=["content_type", "object_id"], name="epdb_additi_content_44d4b4_idx"
                    ),
                    models.Index(
                        fields=["scenario", "content_type", "object_id"],
                        name="epdb_additi_scenari_ef2bf5_idx",
                    ),
                ],
                "constraints": [
                    models.CheckConstraint(
                        condition=models.Q(
                            models.Q(("content_type__isnull", True), ("object_id__isnull", True)),
                            models.Q(("content_type__isnull", False), ("object_id__isnull", False)),
                            _connector="OR",
                        ),
                        name="ck_addinfo_gfk_pair",
                    ),
                    models.CheckConstraint(
                        condition=models.Q(
                            ("scenario__isnull", False),
                            ("content_type__isnull", False),
                            _connector="OR",
                        ),
                        name="ck_addinfo_not_both_null",
                    ),
                ],
            },
        ),
    ]
