# Generated by Django 5.2.8 on 2025-11-11 09:38

from django.db import migrations


def delete_legacy_tokens(apps, schema_editor):
    """
    Delete legacy knox.AuthToken objects. Old tokens would have been invalid
    after the django-rest-knox v5.x upgrade, so they can be removed at this
    point.
    """
    AuthToken = apps.get_model('knox', 'AuthToken')
    AuthToken.objects.all().delete()


class Migration(migrations.Migration):

    dependencies = [
        ('tokens', '0001_rename_plugin'),
    ]

    operations = [
        migrations.RunPython(
            code=delete_legacy_tokens, reverse_code=migrations.RunPython.noop
        ),
        migrations.RunSQL(
            'DROP TABLE IF EXISTS knox_authtoken',
            reverse_sql=migrations.RunSQL.noop,
        ),
    ]
