# Generated by Django 4.2.29 on 2026-03-12 09:43

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


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name="Team",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("name", models.CharField(max_length=255, unique=True)),
                ("description", models.TextField(blank=True)),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
            ],
            options={
                "verbose_name": "Team",
                "verbose_name_plural": "Teams",
                "ordering": ["name"],
            },
        ),
        migrations.CreateModel(
            name="UsageMetric",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("endpoint", models.CharField(max_length=512)),
                ("date", models.DateField()),
                ("request_count", models.IntegerField(default=0)),
                ("error_count", models.IntegerField(default=0)),
                ("average_latency", models.FloatField(default=0.0)),
            ],
            options={
                "verbose_name": "Usage Metric",
                "verbose_name_plural": "Usage Metrics",
                "indexes": [
                    models.Index(fields=["date"], name="modern_drf__date_7d623d_idx")
                ],
                "unique_together": {("endpoint", "date")},
            },
        ),
        migrations.CreateModel(
            name="EndpointPermission",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "path",
                    models.CharField(
                        help_text="The endpoint path (e.g. /api/users/)", max_length=255
                    ),
                ),
                (
                    "methods",
                    models.CharField(
                        help_text="Comma separated methods (e.g. GET,POST) or * for all",
                        max_length=255,
                    ),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                (
                    "team",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="endpoint_permissions",
                        to="modern_drf_swagger.team",
                    ),
                ),
            ],
            options={
                "verbose_name": "Endpoint Permission",
                "verbose_name_plural": "Endpoint Permissions",
            },
        ),
        migrations.CreateModel(
            name="TeamMember",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "role",
                    models.CharField(
                        choices=[
                            ("SUPER_ADMIN", "Super Admin"),
                            ("ADMIN", "Admin"),
                            ("DEVELOPER", "Developer"),
                            ("VIEWER", "Viewer"),
                        ],
                        default="DEVELOPER",
                        max_length=20,
                    ),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                (
                    "team",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="members",
                        to="modern_drf_swagger.team",
                    ),
                ),
                (
                    "user",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="modern_drf_swagger_teams",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "verbose_name": "Team Member",
                "verbose_name_plural": "Team Members",
                "unique_together": {("team", "user")},
            },
        ),
        migrations.CreateModel(
            name="RequestLog",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("endpoint", models.CharField(max_length=512)),
                ("method", models.CharField(max_length=10)),
                ("request_payload", models.TextField(blank=True, null=True)),
                ("response_status", models.IntegerField()),
                (
                    "response_size",
                    models.IntegerField(default=0, help_text="Response size in bytes"),
                ),
                ("latency", models.FloatField(help_text="Latency in milliseconds")),
                ("timestamp", models.DateTimeField(auto_now_add=True)),
                (
                    "user",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="modern_drf_swagger_requests",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "verbose_name": "Request Log",
                "verbose_name_plural": "Request Logs",
                "ordering": ["-timestamp"],
                "indexes": [
                    models.Index(
                        fields=["endpoint"], name="modern_drf__endpoin_18ab6b_idx"
                    ),
                    models.Index(
                        fields=["user"], name="modern_drf__user_id_a38b54_idx"
                    ),
                    models.Index(
                        fields=["timestamp"], name="modern_drf__timesta_185720_idx"
                    ),
                ],
            },
        ),
    ]
