# Generated by Django 5.0 on 2023-12-31 11:29

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

import django_fast_iprestrict.validators


class Migration(migrations.Migration):
    dependencies = [
        ("django_fast_iprestrict", "0004_cleanup_rule"),
    ]

    operations = [
        migrations.AlterField(
            model_name="rule",
            name="action",
            field=models.CharField(
                choices=[
                    ("a", "allow"),
                    ("b", "deny"),
                    ("c", "disabled"),
                    ("d", "only apply ratelimit"),
                ],
                default="c",
                max_length=1,
            ),
        ),
        migrations.AlterField(
            model_name="rulesource",
            name="generator_fn",
            field=models.CharField(
                max_length=200,
                validators=[django_fast_iprestrict.validators.validate_generator_fn],
            ),
        ),
        migrations.CreateModel(
            name="RuleRatelimit",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "key",
                    models.CharField(
                        max_length=200,
                        validators=[
                            django_fast_iprestrict.validators.validate_ratelimit_key
                        ],
                    ),
                ),
                ("group", models.CharField(max_length=50)),
                (
                    "decorate_name",
                    models.CharField(blank=True, default="ratelimit", max_length=50),
                ),
                (
                    "rate",
                    models.CharField(
                        max_length=10,
                        validators=[django_fast_iprestrict.validators.validate_rate],
                    ),
                ),
                ("block", models.BooleanField(blank=True, default=False)),
                ("wait", models.BooleanField(blank=True, default=False)),
                ("is_active", models.BooleanField(blank=True, default=True)),
                (
                    "rule",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="ratelimits",
                        to="django_fast_iprestrict.rule",
                    ),
                ),
            ],
        ),
    ]
