# Generated by Django 4.2.8 on 2024-05-07 09:46

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


class Migration(migrations.Migration):

    dependencies = [
        ("extras", "0106_bookmark_user_cascade_deletion"),
        ("cesnet_service_path_plugin", "0002_servicepath"),
    ]

    operations = [
        migrations.CreateModel(
            name="ServicePathSegmentMapping",
            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,
                    ),
                ),
                ("index", models.IntegerField(default=0)),
                (
                    "segment",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="cesnet_service_path_plugin.segment",
                    ),
                ),
                (
                    "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", "segment", "index"),
                "unique_together": {("service_path", "segment", "index")},
            },
        ),
        migrations.AddField(
            model_name="servicepath",
            name="segments",
            field=models.ManyToManyField(
                through="cesnet_service_path_plugin.ServicePathSegmentMapping",
                to="cesnet_service_path_plugin.segment",
            ),
        ),
    ]
