# Generated by Django 5.2.5 on 2025-12-14 16:34
from django.db import migrations


def migrate_tokens_forward(apps, schema_editor):
    Token = apps.get_model("authtoken", "Token")
    ApiToken = apps.get_model("bookmarks", "ApiToken")

    for old_token in Token.objects.all():
        ApiToken.objects.create(
            key=old_token.key,
            user=old_token.user,
            name="Default Token",
            created=old_token.created,
        )


def migrate_tokens_reverse(apps, schema_editor):
    ApiToken = apps.get_model("bookmarks", "ApiToken")
    ApiToken.objects.filter(name="Default Token").delete()


class Migration(migrations.Migration):
    dependencies = [
        ("bookmarks", "0052_apitoken"),
        ("authtoken", "0004_alter_tokenproxy_options"),
    ]

    operations = [
        migrations.RunPython(migrate_tokens_forward, migrate_tokens_reverse),
    ]
