# Generated by Plain 0.52.2 on 2025-07-08 01:17

import plain.models.deletion
from plain import models
from plain.models import migrations
from plain.runtime import settings


class Migration(migrations.Migration):
    initial = True

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

    operations = [
        migrations.CreateModel(
            name="OAuthConnection",
            fields=[
                ("id", models.PrimaryKeyField()),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                ("provider_key", models.CharField(max_length=100)),
                ("provider_user_id", models.CharField(max_length=100)),
                ("access_token", models.CharField(max_length=2000)),
                ("refresh_token", models.CharField(max_length=2000, required=False)),
                (
                    "access_token_expires_at",
                    models.DateTimeField(allow_null=True, required=False),
                ),
                (
                    "refresh_token_expires_at",
                    models.DateTimeField(allow_null=True, required=False),
                ),
                (
                    "user",
                    models.ForeignKeyField(
                        on_delete=plain.models.deletion.CASCADE,
                        to="users.user",
                    ),
                ),
            ],
            options={
                "ordering": ("provider_key",),
            },
        ),
        migrations.AddConstraint(
            model_name="oauthconnection",
            constraint=models.UniqueConstraint(
                fields=("provider_key", "provider_user_id"),
                name="plainoauth_oauthconnection_unique_provider_key_user_id",
            ),
        ),
    ]
