"""Migration to add RateLimitLeakyBucket model for leaky bucket algorithm."""

# Generated by Django 5.2.4 on 2026-01-20 06:27

from django.db import migrations, models


class Migration(migrations.Migration):
    """Add RateLimitLeakyBucket model for leaky bucket rate limiting."""

    dependencies = [
        ("django_smart_ratelimit", "0001_initial"),
    ]

    operations = [
        migrations.CreateModel(
            name="RateLimitLeakyBucket",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "key",
                    models.CharField(
                        help_text="Rate limit key (unique per bucket)",
                        max_length=255,
                        unique=True,
                    ),
                ),
                (
                    "level",
                    models.FloatField(
                        default=0, help_text="Current fill level of the bucket"
                    ),
                ),
                (
                    "last_leak",
                    models.DateTimeField(help_text="When the bucket was last updated"),
                ),
                (
                    "bucket_capacity",
                    models.PositiveIntegerField(
                        help_text="Maximum capacity of the bucket"
                    ),
                ),
                (
                    "leak_rate",
                    models.FloatField(
                        help_text="Rate at which the bucket leaks (requests per second)"
                    ),
                ),
                (
                    "created_at",
                    models.DateTimeField(
                        auto_now_add=True, help_text="When this bucket was created"
                    ),
                ),
            ],
            options={
                "verbose_name": "Rate Limit Leaky Bucket",
                "verbose_name_plural": "Rate Limit Leaky Buckets",
                "db_table": "ratelimit_leaky_bucket",
                "indexes": [models.Index(fields=["key"], name="ratelimit_leaky_key")],
            },
        ),
    ]
