# Generated by Django 5.2.11 on 2026-02-17 11:04

import django.contrib.postgres.fields
from django.db import migrations, models


def migrate_default_grant_types():
    from authentik.providers.oauth2.models import GrantType

    return [
        GrantType.AUTHORIZATION_CODE,
        GrantType.HYBRID,
        GrantType.IMPLICIT,
        GrantType.CLIENT_CREDENTIALS,
        GrantType.PASSWORD,
        GrantType.DEVICE_CODE,
        GrantType.REFRESH_TOKEN,
    ]


class Migration(migrations.Migration):

    dependencies = [
        (
            "authentik_providers_oauth2",
            "0031_remove_oauth2provider_backchannel_logout_uri_and_more",
        ),
    ]

    operations = [
        migrations.AddField(
            model_name="oauth2provider",
            name="grant_types",
            field=django.contrib.postgres.fields.ArrayField(
                base_field=models.TextField(
                    choices=[
                        ("authorization_code", "Authorization Code"),
                        ("implicit", "Implicit"),
                        ("hybrid", "Hybrid"),
                        ("refresh_token", "Refresh Token"),
                        ("client_credentials", "Client Credentials"),
                        ("password", "Password"),
                        ("urn:ietf:params:oauth:grant-type:device_code", "Device Code"),
                    ]
                ),
                default=migrate_default_grant_types,
                size=None,
            ),
        ),
        migrations.AlterField(
            model_name="oauth2provider",
            name="grant_types",
            field=django.contrib.postgres.fields.ArrayField(
                base_field=models.TextField(
                    choices=[
                        ("authorization_code", "Authorization Code"),
                        ("implicit", "Implicit"),
                        ("hybrid", "Hybrid"),
                        ("refresh_token", "Refresh Token"),
                        ("client_credentials", "Client Credentials"),
                        ("password", "Password"),
                        ("urn:ietf:params:oauth:grant-type:device_code", "Device Code"),
                    ]
                ),
                default=list,
                size=None,
            ),
        ),
    ]
