# Generated by Django 5.1.5 on 2025-02-28 10:46

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


class Migration(migrations.Migration):

    dependencies = [
        ("services", "0009_consultingpartner_address_consultingpartner_email_and_more"),
    ]

    operations = [
        # 1. First create new models
        migrations.CreateModel(
            name="ReusableText",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("name", models.CharField(max_length=100)),
                ("text", models.TextField()),
            ],
            options={
                "ordering": ["name"],
            },
        ),
        # 2. Modify models that will be kept
        migrations.AlterModelOptions(
            name="plan",
            options={"ordering": ["name"]},
        ),
        migrations.RemoveField(
            model_name="plan",
            name="features",
        ),
        migrations.RemoveField(
            model_name="plan",
            name="is_default",
        ),
        migrations.RemoveField(
            model_name="plan",
            name="order",
        ),
        migrations.RemoveField(
            model_name="serviceoffering",
            name="status",
        ),
        migrations.AlterField(
            model_name="serviceoffering",
            name="description",
            field=models.TextField(blank=True, null=True),
        ),
        # 3. Add new models and relationships
        migrations.CreateModel(
            name="ExternalLinkOffering",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("url", models.URLField()),
                ("description", models.CharField(max_length=200)),
                ("order", models.IntegerField(default=0)),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                (
                    "offering",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="external_links",
                        to="services.serviceoffering",
                    ),
                ),
            ],
            options={
                "verbose_name": "External Link",
                "verbose_name_plural": "External Links",
                "ordering": ["order", "description"],
            },
        ),
        migrations.AddField(
            model_name="plan",
            name="plan_description",
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.PROTECT,
                related_name="plan_descriptions",
                to="services.reusabletext",
            ),
        ),
        migrations.AddField(
            model_name="serviceoffering",
            name="offer_description",
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.PROTECT,
                related_name="offer_descriptions",
                to="services.reusabletext",
            ),
        ),
        # 4. Handle PlanPrice modifications and deletion
        migrations.AlterUniqueTogether(
            name="planprice",
            unique_together=None,
        ),
        migrations.RemoveField(
            model_name="planprice",
            name="plan",
        ),
        migrations.RemoveField(
            model_name="planprice",
            name="term",
        ),
        migrations.RemoveField(
            model_name="planprice",
            name="currency",
        ),
        # 5. Delete models in the right order (dependent models first)
        migrations.DeleteModel(
            name="PlanPrice",
        ),
        migrations.DeleteModel(
            name="Currency",
        ),
        migrations.DeleteModel(
            name="Term",
        ),
    ]
