# Generated by Django 5.1.5 on 2025-04-28 07:12

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


class Migration(migrations.Migration):

    dependencies = [
        ('user_management', '0004_operatoraccount_uuid_alter_operatoraccount_id'),
    ]

    operations = [
        migrations.AlterModelOptions(
            name='gmailcredential',
            options={'ordering': ['-is_default', '-updated_at'], 'verbose_name': 'Gmail凭证', 'verbose_name_plural': 'Gmail凭证'},
        ),
        migrations.AlterUniqueTogether(
            name='gmailcredential',
            unique_together={('user', 'gmail_email')},
        ),
        migrations.AddField(
            model_name='gmailcredential',
            name='credentials_json',
            field=models.TextField(blank=True, null=True, verbose_name='凭证JSON'),
        ),
        migrations.AddField(
            model_name='gmailcredential',
            name='gmail_credential_id',
            field=models.CharField(blank=True, max_length=255, null=True, verbose_name='Gmail凭证ID'),
        ),
        migrations.AddField(
            model_name='gmailcredential',
            name='needs_reauth',
            field=models.BooleanField(default=False, verbose_name='需要重新授权'),
        ),
        migrations.AlterField(
            model_name='gmailcredential',
            name='created_at',
            field=models.DateTimeField(auto_now_add=True, verbose_name='创建时间'),
        ),
        migrations.AlterField(
            model_name='gmailcredential',
            name='gmail_email',
            field=models.EmailField(default='your_default_email@example.com', max_length=255, verbose_name='Gmail邮箱'),
        ),
        migrations.AlterField(
            model_name='gmailcredential',
            name='is_active',
            field=models.BooleanField(default=True, verbose_name='是否活跃'),
        ),
        migrations.AlterField(
            model_name='gmailcredential',
            name='is_default',
            field=models.BooleanField(default=False, verbose_name='是否默认'),
        ),
        migrations.AlterField(
            model_name='gmailcredential',
            name='last_history_id',
            field=models.CharField(blank=True, max_length=100, null=True, verbose_name='最后历史ID'),
        ),
        migrations.AlterField(
            model_name='gmailcredential',
            name='name',
            field=models.CharField(default='默认Gmail', max_length=100, verbose_name='名称'),
        ),
        migrations.AlterField(
            model_name='gmailcredential',
            name='token_path',
            field=models.CharField(blank=True, max_length=255, null=True, verbose_name='令牌路径'),
        ),
        migrations.AlterField(
            model_name='gmailcredential',
            name='updated_at',
            field=models.DateTimeField(auto_now=True, verbose_name='更新时间'),
        ),
        migrations.AlterField(
            model_name='gmailcredential',
            name='watch_expiration',
            field=models.DateTimeField(blank=True, null=True, verbose_name='监听过期时间'),
        ),
        migrations.AlterModelTable(
            name='gmailcredential',
            table=None,
        ),
        migrations.CreateModel(
            name='GmailNotificationQueue',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('email', models.EmailField(max_length=255, verbose_name='邮箱')),
                ('history_id', models.CharField(max_length=100, verbose_name='历史ID')),
                ('notification_data', models.TextField(blank=True, null=True, verbose_name='通知数据')),
                ('processed', models.BooleanField(default=False, verbose_name='是否已处理')),
                ('success', models.BooleanField(default=False, verbose_name='处理是否成功')),
                ('error_message', models.CharField(blank=True, max_length=255, null=True, verbose_name='错误信息')),
                ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='创建时间')),
                ('processed_at', models.DateTimeField(blank=True, null=True, verbose_name='处理时间')),
                ('gmail_credential', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='notification_queue', to='user_management.gmailcredential')),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='gmail_notification_queue', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'verbose_name': 'Gmail通知队列',
                'verbose_name_plural': 'Gmail通知队列',
                'ordering': ['processed', 'created_at'],
            },
        ),
        migrations.RemoveField(
            model_name='gmailcredential',
            name='credentials',
        ),
    ]
