# Generated by Django 5.2.7 on 2025-10-31 15:27

from django.db import migrations, models


def migrate_kadmin_type(apps, schema_editor):
    KerberosSource = apps.get_model("authentik_sources_kerberos", "KerberosSource")
    db_alias = schema_editor.connection.alias

    for source in KerberosSource.objects.using(db_alias).all():
        if source.kadmin_type not in ("MIT", "Heimdal"):
            source.kadmin_type = "MIT"
            source.save(using=db_alias)


class Migration(migrations.Migration):
    dependencies = [
        ("authentik_sources_kerberos", "0004_kerberossource_sync_outgoing_trigger_mode"),
    ]

    operations = [
        migrations.RunPython(migrate_kadmin_type, reverse_code=migrations.RunPython.noop),
        migrations.AlterField(
            model_name="kerberossource",
            name="kadmin_type",
            field=models.TextField(
                choices=[("MIT", "Mit"), ("Heimdal", "Heimdal")],
                default="MIT",
                help_text="KAdmin server type",
            ),
        ),
    ]
