from __future__ import annotations

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


class Migration(migrations.Migration):  # type: ignore[misc]
    initial = True

    dependencies = [  # ruff: ignore[mutable-class-default]
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [  # ruff: ignore[mutable-class-default]
        migrations.CreateModel(
            name="MqttToken",
            fields=[
                ("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
                ("key_digest", models.CharField(db_index=True, max_length=64, unique=True)),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("revoked_at", models.DateTimeField(blank=True, null=True)),
                (
                    "user",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="amqtt_tokens",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "indexes": [models.Index(fields=["user", "revoked_at"], name="amqtt_djang_user_id_940ff1_idx")],
            },
        ),
    ]
