# Generated by Django 4.1.4 on 2023-01-01 00:38

import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ("users", "0008_follow_boosts"),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ("api", "0001_initial"),
    ]

    operations = [
        migrations.RemoveField(
            model_name="token",
            name="code",
        ),
        migrations.AddField(
            model_name="token",
            name="revoked",
            field=models.DateTimeField(blank=True, null=True),
        ),
        migrations.AlterField(
            model_name="token",
            name="token",
            field=models.CharField(max_length=500, unique=True),
        ),
        migrations.CreateModel(
            name="Authorization",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "code",
                    models.CharField(
                        blank=True, max_length=128, null=True, unique=True
                    ),
                ),
                ("scopes", models.JSONField()),
                ("redirect_uri", models.TextField(blank=True, null=True)),
                ("valid_for_seconds", models.IntegerField(default=60)),
                ("created", models.DateTimeField(auto_now_add=True)),
                ("updated", models.DateTimeField(auto_now=True)),
                (
                    "application",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="authorizations",
                        to="api.application",
                    ),
                ),
                (
                    "identity",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="authorizations",
                        to="users.identity",
                    ),
                ),
                (
                    "token",
                    models.OneToOneField(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        to="api.token",
                    ),
                ),
                (
                    "user",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="authorizations",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
        ),
    ]
