Files
DEMO-AGENT/review_agent/migrations/0007_feishuaccesstokencache_feishuusermapping_and_more.py

353 lines
13 KiB
Python

# Generated by Django 5.2.14 on 2026-06-07 14:02
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("review_agent", "0006_alter_exportedsummaryfile_export_type_and_more"),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.CreateModel(
name="FeishuAccessTokenCache",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("app_id_hash", models.CharField(max_length=128, unique=True)),
("tenant_access_token", models.TextField(blank=True, default="")),
("expires_at", models.DateTimeField(blank=True, null=True)),
("error_message", models.TextField(blank=True, default="")),
("created_at", models.DateTimeField(auto_now_add=True)),
("updated_at", models.DateTimeField(auto_now=True)),
],
options={
"db_table": "ra_feishu_access_token_cache",
"ordering": ["-updated_at", "-id"],
"indexes": [
models.Index(
fields=["app_id_hash"], name="idx_ra_feishu_token_app"
),
models.Index(fields=["expires_at"], name="idx_ra_feishu_token_exp"),
],
},
),
migrations.CreateModel(
name="FeishuUserMapping",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
(
"feishu_display_name",
models.CharField(blank=True, default="", max_length=120),
),
(
"feishu_open_id",
models.CharField(blank=True, default="", max_length=120),
),
(
"feishu_user_id",
models.CharField(blank=True, default="", max_length=120),
),
(
"feishu_mobile",
models.CharField(blank=True, default="", max_length=40),
),
("is_active", models.BooleanField(default=True)),
("remark", models.CharField(blank=True, default="", max_length=255)),
("created_at", models.DateTimeField(auto_now_add=True)),
("updated_at", models.DateTimeField(auto_now=True)),
(
"system_user",
models.OneToOneField(
on_delete=django.db.models.deletion.CASCADE,
related_name="feishu_mapping",
to=settings.AUTH_USER_MODEL,
),
),
],
options={
"db_table": "ra_feishu_user_mapping",
"ordering": ["system_user__username", "id"],
},
),
migrations.CreateModel(
name="FeishuQuestionLog",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
(
"feishu_open_id",
models.CharField(blank=True, default="", max_length=120),
),
(
"feishu_user_id",
models.CharField(blank=True, default="", max_length=120),
),
(
"source_type",
models.CharField(
choices=[
("private_chat", "私聊"),
("group_mention", "群聊 @"),
("simulate", "本地模拟"),
],
default="simulate",
max_length=30,
),
),
(
"message_id",
models.CharField(blank=True, default="", max_length=120),
),
("question_text", models.TextField()),
("intent", models.CharField(blank=True, default="", max_length=60)),
("query_object", models.JSONField(blank=True, default=dict)),
("answer_summary", models.TextField(blank=True, default="")),
(
"permission_result",
models.CharField(blank=True, default="", max_length=40),
),
(
"status",
models.CharField(
choices=[
("success", "成功"),
("failed", "失败"),
("ignored", "忽略"),
],
default="success",
max_length=30,
),
),
("error_message", models.TextField(blank=True, default="")),
("processed_at", models.DateTimeField(blank=True, null=True)),
("created_at", models.DateTimeField(auto_now_add=True)),
(
"system_user",
models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="feishu_question_logs",
to=settings.AUTH_USER_MODEL,
),
),
(
"feishu_mapping",
models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="question_logs",
to="review_agent.feishuusermapping",
),
),
],
options={
"db_table": "ra_feishu_question_log",
"ordering": ["-created_at", "-id"],
},
),
migrations.CreateModel(
name="WorkflowNotificationRecord",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("workflow_type", models.CharField(max_length=40)),
("workflow_batch_id", models.PositiveBigIntegerField()),
("workflow_batch_no", models.CharField(max_length=80)),
("workflow_status", models.CharField(max_length=40)),
("dedupe_key", models.CharField(max_length=160)),
(
"channel",
models.CharField(
choices=[
("mock", "模拟"),
("disabled", "未启用"),
("feishu_api", "飞书 API"),
],
default="mock",
max_length=40,
),
),
("target", models.CharField(blank=True, default="", max_length=160)),
(
"at_display_name",
models.CharField(blank=True, default="", max_length=120),
),
(
"at_identifier_type",
models.CharField(blank=True, default="", max_length=30),
),
(
"at_identifier_masked",
models.CharField(blank=True, default="", max_length=120),
),
(
"send_status",
models.CharField(
choices=[
("pending", "待发送"),
("success", "成功"),
("failed", "失败"),
("skipped_duplicate", "重复跳过"),
("disabled", "未启用"),
],
default="pending",
max_length=30,
),
),
("message_title", models.CharField(max_length=200)),
("message_summary", models.TextField(blank=True, default="")),
(
"result_url",
models.CharField(blank=True, default="", max_length=500),
),
(
"external_message_id",
models.CharField(blank=True, default="", max_length=120),
),
("error_code", models.CharField(blank=True, default="", max_length=80)),
("error_message", models.TextField(blank=True, default="")),
(
"request_duration_ms",
models.PositiveIntegerField(blank=True, null=True),
),
("sent_at", models.DateTimeField(blank=True, null=True)),
("created_at", models.DateTimeField(auto_now_add=True)),
("updated_at", models.DateTimeField(auto_now=True)),
(
"feishu_mapping",
models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="notification_records",
to="review_agent.feishuusermapping",
),
),
(
"trigger_user",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="workflow_notification_records",
to=settings.AUTH_USER_MODEL,
),
),
],
options={
"db_table": "ra_workflow_notification_record",
"ordering": ["-created_at", "-id"],
},
),
migrations.AddIndex(
model_name="feishuusermapping",
index=models.Index(fields=["is_active"], name="idx_ra_feishu_map_active"),
),
migrations.AddIndex(
model_name="feishuusermapping",
index=models.Index(
fields=["feishu_open_id"], name="idx_ra_feishu_map_open"
),
),
migrations.AddIndex(
model_name="feishuusermapping",
index=models.Index(
fields=["feishu_user_id"], name="idx_ra_feishu_map_userid"
),
),
migrations.AddIndex(
model_name="feishuusermapping",
index=models.Index(
fields=["feishu_mobile"], name="idx_ra_feishu_map_mobile"
),
),
migrations.AddIndex(
model_name="feishuquestionlog",
index=models.Index(
fields=["system_user", "created_at"],
name="idx_ra_feishu_q_user_created",
),
),
migrations.AddIndex(
model_name="feishuquestionlog",
index=models.Index(
fields=["intent", "created_at"], name="idx_ra_feishu_q_intent"
),
),
migrations.AddIndex(
model_name="feishuquestionlog",
index=models.Index(
fields=["status", "created_at"], name="idx_ra_feishu_q_status"
),
),
migrations.AddIndex(
model_name="feishuquestionlog",
index=models.Index(fields=["message_id"], name="idx_ra_feishu_q_message"),
),
migrations.AddIndex(
model_name="workflownotificationrecord",
index=models.Index(
fields=["workflow_type", "workflow_batch_id"],
name="idx_ra_notify_workflow",
),
),
migrations.AddIndex(
model_name="workflownotificationrecord",
index=models.Index(
fields=["trigger_user", "created_at"], name="idx_ra_notify_user_created"
),
),
migrations.AddIndex(
model_name="workflownotificationrecord",
index=models.Index(
fields=["send_status", "created_at"], name="idx_ra_notify_status"
),
),
migrations.AddIndex(
model_name="workflownotificationrecord",
index=models.Index(
fields=["workflow_batch_no"], name="idx_ra_notify_batch_no"
),
),
migrations.AddIndex(
model_name="workflownotificationrecord",
index=models.Index(
fields=["dedupe_key", "send_status"], name="idx_ra_notify_dedupe_status"
),
),
]