# Generated by Django 5.0.6 on 2024-06-03 07:43

import django.db.models.deletion
import taggit.managers
import utilities.json
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ("circuits", "0043_circuittype_color"),
        ("extras", "0115_convert_dashboard_widgets"),
        (
            "cesnet_service_path_plugin",
            "0004_add_komora_id_and_imported_data_to_models",
        ),
    ]

    operations = [
        migrations.CreateModel(
            name="SegmentCircuitMapping",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False
                    ),
                ),
                ("created", models.DateTimeField(auto_now_add=True, null=True)),
                ("last_updated", models.DateTimeField(auto_now=True, null=True)),
                (
                    "custom_field_data",
                    models.JSONField(
                        blank=True,
                        default=dict,
                        encoder=utilities.json.CustomFieldJSONEncoder,
                    ),
                ),
                (
                    "circuit",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="circuits.circuit",
                    ),
                ),
                (
                    "segment",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="cesnet_service_path_plugin.segment",
                    ),
                ),
                (
                    "tags",
                    taggit.managers.TaggableManager(
                        through="extras.TaggedItem", to="extras.Tag"
                    ),
                ),
            ],
            options={
                "ordering": ("segment", "circuit"),
                "unique_together": {("segment", "circuit")},
            },
        ),
        migrations.AddField(
            model_name="segment",
            name="circuits",
            field=models.ManyToManyField(
                through="cesnet_service_path_plugin.SegmentCircuitMapping",
                to="circuits.circuit",
            ),
        ),
        migrations.CreateModel(
            name="ServicePathCircuitMapping",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False
                    ),
                ),
                ("created", models.DateTimeField(auto_now_add=True, null=True)),
                ("last_updated", models.DateTimeField(auto_now=True, null=True)),
                (
                    "custom_field_data",
                    models.JSONField(
                        blank=True,
                        default=dict,
                        encoder=utilities.json.CustomFieldJSONEncoder,
                    ),
                ),
                (
                    "circuit",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="circuits.circuit",
                    ),
                ),
                (
                    "service_path",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="cesnet_service_path_plugin.servicepath",
                    ),
                ),
                (
                    "tags",
                    taggit.managers.TaggableManager(
                        through="extras.TaggedItem", to="extras.Tag"
                    ),
                ),
            ],
            options={
                "ordering": ("service_path", "circuit"),
                "unique_together": {("service_path", "circuit")},
            },
        ),
        migrations.AddField(
            model_name="servicepath",
            name="circuits",
            field=models.ManyToManyField(
                through="cesnet_service_path_plugin.ServicePathCircuitMapping",
                to="circuits.circuit",
            ),
        ),
    ]
