# Generated by Django 5.2.8 on 2025-11-27 00:16

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


class Migration(migrations.Migration):

    dependencies = [
        ("authentik_endpoints", "0002_rename_devicegroup_deviceaccessgroup_and_more"),
        ("authentik_endpoints_connectors_agent", "0001_initial"),
        (
            "authentik_providers_oauth2",
            "0031_remove_oauth2provider_backchannel_logout_uri_and_more",
        ),
    ]

    operations = [
        migrations.CreateModel(
            name="DeviceAuthenticationToken",
            fields=[
                ("expires", models.DateTimeField(default=None, null=True)),
                ("expiring", models.BooleanField(default=True)),
                (
                    "identifier",
                    models.UUIDField(default=uuid.uuid4, primary_key=True, serialize=False),
                ),
                ("token", models.TextField()),
            ],
            options={
                "verbose_name": "Device authentication token",
                "verbose_name_plural": "Device authentication tokens",
                "abstract": False,
            },
        ),
        migrations.AlterModelOptions(
            name="devicetoken",
            options={"verbose_name": "Device Token", "verbose_name_plural": "Device Tokens"},
        ),
        migrations.RenameField(
            model_name="agentconnector",
            old_name="authentication_flow",
            new_name="authorization_flow",
        ),
        migrations.AddField(
            model_name="agentconnector",
            name="jwt_federation_providers",
            field=models.ManyToManyField(
                blank=True, default=None, to="authentik_providers_oauth2.oauth2provider"
            ),
        ),
        migrations.AddIndex(
            model_name="devicetoken",
            index=models.Index(fields=["key"], name="authentik_e_key_504bbc_idx"),
        ),
        migrations.AddField(
            model_name="deviceauthenticationtoken",
            name="connector",
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                to="authentik_endpoints_connectors_agent.agentconnector",
            ),
        ),
        migrations.AddField(
            model_name="deviceauthenticationtoken",
            name="device",
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE, to="authentik_endpoints.device"
            ),
        ),
        migrations.AddField(
            model_name="deviceauthenticationtoken",
            name="device_token",
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                to="authentik_endpoints_connectors_agent.devicetoken",
            ),
        ),
        migrations.AddIndex(
            model_name="deviceauthenticationtoken",
            index=models.Index(fields=["expires"], name="authentik_e_expires_d52fb2_idx"),
        ),
        migrations.AddIndex(
            model_name="deviceauthenticationtoken",
            index=models.Index(fields=["expiring"], name="authentik_e_expirin_e9b873_idx"),
        ),
        migrations.AddIndex(
            model_name="deviceauthenticationtoken",
            index=models.Index(
                fields=["expiring", "expires"], name="authentik_e_expirin_8c95fe_idx"
            ),
        ),
    ]
