# Generated by Django 5.2b1 on 2025-03-16 08:44

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

import servala.core.models.user


class Migration(migrations.Migration):

    initial = True

    dependencies = []

    operations = [
        migrations.CreateModel(
            name="User",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("password", models.CharField(max_length=128, verbose_name="password")),
                (
                    "last_login",
                    models.DateTimeField(
                        blank=True, null=True, verbose_name="last login"
                    ),
                ),
                (
                    "email",
                    models.EmailField(
                        max_length=254, unique=True, verbose_name="Email address"
                    ),
                ),
                (
                    "first_name",
                    models.CharField(
                        blank=True, max_length=30, verbose_name="First name"
                    ),
                ),
                (
                    "last_name",
                    models.CharField(
                        blank=True, max_length=30, verbose_name="Last name"
                    ),
                ),
                (
                    "company",
                    models.CharField(
                        blank=True, max_length=100, verbose_name="Company"
                    ),
                ),
                (
                    "is_staff",
                    models.BooleanField(
                        default=False,
                        help_text="Staff users can log into this admin site.",
                        verbose_name="Is staff",
                    ),
                ),
                (
                    "is_superuser",
                    models.BooleanField(
                        default=False,
                        help_text="Superusers have all permissions without explicitly assigning them. Use with caution.",
                        verbose_name="Is superuser",
                    ),
                ),
            ],
            options={
                "verbose_name": "User",
                "verbose_name_plural": "Users",
            },
            managers=[
                ("objects", servala.core.models.user.UserManager()),
            ],
        ),
        migrations.CreateModel(
            name="BillingEntity",
            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"),
                ),
                (
                    "erp_reference",
                    models.CharField(
                        blank=True, max_length=100, verbose_name="ERP reference"
                    ),
                ),
            ],
            options={
                "verbose_name": "Billing entity",
                "verbose_name_plural": "Billing entities",
            },
        ),
        migrations.CreateModel(
            name="CloudProvider",
            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"),
                ),
                (
                    "logo",
                    models.ImageField(
                        blank=True,
                        null=True,
                        upload_to="public/service_providers",
                        verbose_name="Logo",
                    ),
                ),
                (
                    "external_links",
                    models.JSONField(
                        blank=True, null=True, verbose_name="External links"
                    ),
                ),
            ],
            options={
                "verbose_name": "Cloud provider",
                "verbose_name_plural": "Cloud providers",
            },
        ),
        migrations.CreateModel(
            name="OrganizationOrigin",
            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"),
                ),
            ],
            options={
                "verbose_name": "Organization origin",
                "verbose_name_plural": "Organization origins",
            },
        ),
        migrations.CreateModel(
            name="ControlPlane",
            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"),
                ),
                (
                    "k8s_api_endpoint",
                    models.URLField(verbose_name="Kubernetes API endpoint"),
                ),
                ("api_credentials", models.JSONField(verbose_name="API credentials")),
                (
                    "cloud_provider",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="control_planes",
                        to="core.cloudprovider",
                        verbose_name="Cloud provider",
                    ),
                ),
            ],
            options={
                "verbose_name": "Control plane",
                "verbose_name_plural": "Control planes",
            },
        ),
        migrations.CreateModel(
            name="Organization",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("name", models.CharField(max_length=100, verbose_name="Name")),
                (
                    "billing_entity",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="organizations",
                        to="core.billingentity",
                        verbose_name="Billing entity",
                    ),
                ),
            ],
            options={
                "verbose_name": "Organization",
                "verbose_name_plural": "Organizations",
            },
        ),
        migrations.CreateModel(
            name="OrganizationMembership",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "date_joined",
                    models.DateTimeField(auto_now_add=True, verbose_name="Date joined"),
                ),
                (
                    "role",
                    models.CharField(
                        choices=[
                            ("member", "Member"),
                            ("admin", "Administrator"),
                            ("owner", "Owner"),
                        ],
                        default="member",
                        max_length=20,
                        verbose_name="Role",
                    ),
                ),
                (
                    "organization",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="memberships",
                        to="core.organization",
                        verbose_name="Organization",
                    ),
                ),
                (
                    "user",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="organization_memberships",
                        to=settings.AUTH_USER_MODEL,
                        verbose_name="User",
                    ),
                ),
            ],
            options={
                "verbose_name": "Organization membership",
                "verbose_name_plural": "Organization memberships",
            },
        ),
        migrations.AddField(
            model_name="organization",
            name="members",
            field=models.ManyToManyField(
                related_name="organizations",
                through="core.OrganizationMembership",
                to=settings.AUTH_USER_MODEL,
                verbose_name="Members",
            ),
        ),
        migrations.AddField(
            model_name="organization",
            name="origin",
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.PROTECT,
                related_name="organizations",
                to="core.organizationorigin",
                verbose_name="Origin",
            ),
        ),
        migrations.CreateModel(
            name="ServiceCategory",
            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"),
                ),
                (
                    "logo",
                    models.ImageField(
                        blank=True,
                        null=True,
                        upload_to="public/service_categories",
                        verbose_name="Logo",
                    ),
                ),
                (
                    "parent",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="children",
                        to="core.servicecategory",
                        verbose_name="Parent",
                    ),
                ),
            ],
            options={
                "verbose_name": "Service category",
                "verbose_name_plural": "Service categories",
            },
        ),
        migrations.CreateModel(
            name="Service",
            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"),
                ),
                (
                    "logo",
                    models.ImageField(
                        blank=True,
                        null=True,
                        upload_to="public/services",
                        verbose_name="Logo",
                    ),
                ),
                (
                    "external_links",
                    models.JSONField(
                        blank=True, null=True, verbose_name="External links"
                    ),
                ),
                (
                    "category",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="services",
                        to="core.servicecategory",
                        verbose_name="Category",
                    ),
                ),
            ],
            options={
                "verbose_name": "Service",
                "verbose_name_plural": "Services",
            },
        ),
        migrations.CreateModel(
            name="ServiceOffering",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "description",
                    models.TextField(blank=True, verbose_name="Description"),
                ),
                (
                    "control_plane",
                    models.ManyToManyField(
                        related_name="offerings",
                        to="core.controlplane",
                        verbose_name="Control planes",
                    ),
                ),
                (
                    "provider",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="offerings",
                        to="core.cloudprovider",
                        verbose_name="Provider",
                    ),
                ),
                (
                    "service",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="offerings",
                        to="core.service",
                        verbose_name="Service",
                    ),
                ),
            ],
            options={
                "verbose_name": "Service offering",
                "verbose_name_plural": "Service offerings",
            },
        ),
        migrations.CreateModel(
            name="Plan",
            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"),
                ),
                (
                    "features",
                    models.JSONField(blank=True, null=True, verbose_name="Features"),
                ),
                (
                    "pricing",
                    models.JSONField(blank=True, null=True, verbose_name="Pricing"),
                ),
                (
                    "term",
                    models.PositiveIntegerField(
                        help_text="Term in months", verbose_name="Term"
                    ),
                ),
                (
                    "service_offering",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="plans",
                        to="core.serviceoffering",
                        verbose_name="Service offering",
                    ),
                ),
            ],
            options={
                "verbose_name": "Plan",
                "verbose_name_plural": "Plans",
            },
        ),
    ]
