operations_project/apps/gmail/migrations/0001_initial.py

73 lines
4.0 KiB
Python
Raw Normal View History

2025-05-13 18:36:06 +08:00
# Generated by Django 5.2 on 2025-05-13 06:43
2025-05-07 18:01:48 +08:00
import django.db.models.deletion
2025-05-13 18:36:06 +08:00
import django.utils.timezone
2025-05-07 18:01:48 +08:00
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 = [
2025-05-13 18:36:06 +08:00
migrations.CreateModel(
name='GmailConversation',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('user_email', models.EmailField(help_text='用户Gmail邮箱', max_length=254)),
('influencer_email', models.EmailField(help_text='达人Gmail邮箱', max_length=254)),
('conversation_id', models.CharField(help_text='关联到chat_history的会话ID', max_length=100, unique=True)),
('title', models.CharField(default='Gmail对话', help_text='对话标题', max_length=100)),
('last_sync_time', models.DateTimeField(default=django.utils.timezone.now, help_text='最后同步时间')),
('created_at', models.DateTimeField(auto_now_add=True)),
('updated_at', models.DateTimeField(auto_now=True)),
('is_active', models.BooleanField(default=True)),
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='gmail_conversations', to=settings.AUTH_USER_MODEL)),
],
options={
'ordering': ['-updated_at'],
'unique_together': {('user', 'user_email', 'influencer_email')},
},
),
migrations.CreateModel(
name='GmailAttachment',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('email_message_id', models.CharField(help_text='Gmail邮件ID', max_length=100)),
('attachment_id', models.CharField(help_text='Gmail附件ID', max_length=100)),
('filename', models.CharField(help_text='原始文件名', max_length=255)),
('file_path', models.CharField(help_text='保存在服务器上的路径', max_length=255)),
('content_type', models.CharField(help_text='MIME类型', max_length=100)),
('size', models.IntegerField(default=0, help_text='文件大小(字节)')),
('sender_email', models.EmailField(help_text='发送者邮箱', max_length=254)),
('chat_message_id', models.CharField(blank=True, help_text='关联到ChatHistory的消息ID', max_length=100, null=True)),
('created_at', models.DateTimeField(auto_now_add=True)),
('conversation', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='attachments', to='gmail.gmailconversation')),
],
options={
'ordering': ['-created_at'],
},
),
2025-05-07 18:01:48 +08:00
migrations.CreateModel(
name='GmailCredential',
fields=[
2025-05-13 11:58:17 +08:00
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('email', models.EmailField(help_text='Gmail email address', max_length=254, unique=True)),
('credentials', models.TextField(help_text='Serialized OAuth2 credentials (JSON)')),
('is_default', models.BooleanField(default=False, help_text='Default Gmail account for user')),
('created_at', models.DateTimeField(auto_now_add=True)),
('updated_at', models.DateTimeField(auto_now=True)),
('is_valid', models.BooleanField(default=True, help_text='Whether the credential is valid')),
2025-05-07 18:01:48 +08:00
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='gmail_credentials', to=settings.AUTH_USER_MODEL)),
],
options={
2025-05-13 11:58:17 +08:00
'unique_together': {('user', 'email')},
2025-05-07 18:01:48 +08:00
},
),
]