# Generated by Django 5.2.7 on 2025-10-18 03:34

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


class Migration(migrations.Migration):
    initial = True

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name="GoogleOAuthToken",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "access_token",
                    models.TextField(
                        help_text="Google OAuth access token (used for API requests)"
                    ),
                ),
                (
                    "refresh_token",
                    models.TextField(
                        blank=True,
                        help_text=(
                            "Google OAuth refresh token "
                            "(used to get new access tokens)"
                        ),
                        null=True,
                    ),
                ),
                (
                    "token_expiry",
                    models.DateTimeField(
                        blank=True, help_text="When the access token expires", null=True
                    ),
                ),
                (
                    "scopes",
                    models.TextField(
                        blank=True,
                        default="",
                        help_text="Comma-separated list of OAuth scopes granted",
                    ),
                ),
                (
                    "id_token",
                    models.TextField(
                        blank=True,
                        help_text="Google ID token (JWT containing user info)",
                        null=True,
                    ),
                ),
                (
                    "google_id",
                    models.CharField(
                        blank=True,
                        db_index=True,
                        default="",
                        help_text=(
                            "Google's unique user identifier ",
                            "(sub claim from ID token)",
                        ),
                        max_length=255,
                    ),
                ),
                (
                    "created_at",
                    models.DateTimeField(
                        auto_now_add=True, help_text="When this token was first created"
                    ),
                ),
                (
                    "updated_at",
                    models.DateTimeField(
                        auto_now=True, help_text="When this token was last updated"
                    ),
                ),
                (
                    "user",
                    models.OneToOneField(
                        help_text="The user this token belongs to",
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="google_oauth_token",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "verbose_name": "Google OAuth Token",
                "verbose_name_plural": "Google OAuth Tokens",
                "ordering": ["-updated_at"],
                "indexes": [
                    models.Index(
                        fields=["user"], name="django_goog_user_id_3c64a6_idx"
                    ),
                    models.Index(
                        fields=["google_id"], name="django_goog_google__0371b7_idx"
                    ),
                    models.Index(
                        fields=["token_expiry"], name="django_goog_token_e_86a09f_idx"
                    ),
                ],
            },
        ),
    ]
