# Generated by Django 5.2b1 on 2025-03-25 11:02

import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ("core", "0006_service_slug"),
    ]

    operations = [
        migrations.RemoveField(
            model_name="serviceoffering",
            name="control_plane",
        ),
        migrations.CreateModel(
            name="ServiceDefinition",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("name", models.CharField(max_length=100, verbose_name="Name")),
                (
                    "description",
                    models.TextField(blank=True, verbose_name="Description"),
                ),
                (
                    "api_definition",
                    models.JSONField(
                        blank=True,
                        help_text="Contains group, version, and kind information",
                        null=True,
                        verbose_name="API Definition",
                    ),
                ),
                (
                    "service",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="service_definitions",
                        to="core.service",
                        verbose_name="Service",
                    ),
                ),
            ],
            options={
                "verbose_name": "Service definition",
                "verbose_name_plural": "Service definitions",
            },
        ),
        migrations.CreateModel(
            name="ServiceOfferingControlPlane",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "control_plane",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="offering_connections",
                        to="core.controlplane",
                        verbose_name="Control plane",
                    ),
                ),
                (
                    "service_definition",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="offering_control_planes",
                        to="core.servicedefinition",
                        verbose_name="Service definition",
                    ),
                ),
                (
                    "service_offering",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="control_plane_connections",
                        to="core.serviceoffering",
                        verbose_name="Service offering",
                    ),
                ),
            ],
            options={
                "verbose_name": "Service offering control plane connection",
                "verbose_name_plural": "Service offering control planes connections",
                "unique_together": {("service_offering", "control_plane")},
            },
        ),
        migrations.AddField(
            model_name="serviceoffering",
            name="control_planes",
            field=models.ManyToManyField(
                related_name="offerings",
                through="core.ServiceOfferingControlPlane",
                to="core.controlplane",
                verbose_name="Control planes",
            ),
        ),
    ]
