feat(file-summary): 添加文件汇总数据模型

This commit is contained in:
2026-06-06 01:11:11 +08:00
parent b96ab1303a
commit 855afcdee3
6 changed files with 906 additions and 0 deletions

View File

@@ -0,0 +1,481 @@
# Generated by Django 5.2.14 on 2026-06-05 17:09
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("review_agent", "0001_initial"),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.CreateModel(
name="FileAttachment",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("original_name", models.CharField(max_length=255)),
("version_no", models.PositiveIntegerField(default=1)),
("is_active", models.BooleanField(default=True)),
("storage_path", models.CharField(max_length=500)),
("file_size", models.BigIntegerField(default=0)),
(
"content_type",
models.CharField(blank=True, default="", max_length=120),
),
(
"upload_status",
models.CharField(
choices=[
("uploaded", "已上传"),
("bound", "已绑定"),
("deleted", "已删除"),
],
default="uploaded",
max_length=20,
),
),
("created_at", models.DateTimeField(auto_now_add=True)),
(
"conversation",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="file_attachments",
to="review_agent.conversation",
),
),
(
"user",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="review_file_attachments",
to=settings.AUTH_USER_MODEL,
),
),
],
options={
"db_table": "ra_file_attachment",
"ordering": ["-created_at", "-id"],
},
),
migrations.CreateModel(
name="FileSummaryBatch",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("batch_no", models.CharField(max_length=64, unique=True)),
(
"product_name",
models.CharField(blank=True, default="", max_length=200),
),
(
"status",
models.CharField(
choices=[
("pending", "待执行"),
("running", "执行中"),
("success", "成功"),
("failed", "失败"),
],
default="pending",
max_length=20,
),
),
("total_files", models.IntegerField(default=0)),
("supported_files", models.IntegerField(default=0)),
("success_files", models.IntegerField(default=0)),
("failed_files", models.IntegerField(default=0)),
("unsupported_files", models.IntegerField(default=0)),
("uncertain_files", models.IntegerField(default=0)),
("total_pages", models.IntegerField(default=0)),
("work_dir", models.CharField(blank=True, default="", max_length=500)),
("error_message", models.TextField(blank=True, default="")),
("created_at", models.DateTimeField(auto_now_add=True)),
("started_at", models.DateTimeField(blank=True, null=True)),
("finished_at", models.DateTimeField(blank=True, null=True)),
(
"conversation",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="file_summary_batches",
to="review_agent.conversation",
),
),
(
"trigger_message",
models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="triggered_file_summary_batches",
to="review_agent.message",
),
),
(
"user",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="review_file_summary_batches",
to=settings.AUTH_USER_MODEL,
),
),
],
options={
"db_table": "ra_file_summary_batch",
"ordering": ["-created_at", "-id"],
},
),
migrations.CreateModel(
name="ExportedSummaryFile",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
(
"export_type",
models.CharField(
choices=[("markdown", "Markdown"), ("excel", "Excel")],
max_length=20,
),
),
("file_name", models.CharField(max_length=255)),
("storage_path", models.CharField(max_length=500)),
(
"status",
models.CharField(
choices=[("success", "成功"), ("failed", "失败")],
default="success",
max_length=20,
),
),
("error_message", models.TextField(blank=True, default="")),
("created_at", models.DateTimeField(auto_now_add=True)),
(
"batch",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="exports",
to="review_agent.filesummarybatch",
),
),
],
options={
"db_table": "ra_exported_summary_file",
"ordering": ["-created_at", "-id"],
},
),
migrations.CreateModel(
name="FileSummaryBatchAttachment",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
(
"source_role",
models.CharField(
choices=[("archive", "压缩包"), ("multi_file", "多文件")],
default="multi_file",
max_length=20,
),
),
("created_at", models.DateTimeField(auto_now_add=True)),
(
"attachment",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="batch_bindings",
to="review_agent.fileattachment",
),
),
(
"batch",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="batch_attachments",
to="review_agent.filesummarybatch",
),
),
],
options={
"db_table": "ra_file_summary_batch_attachment",
},
),
migrations.CreateModel(
name="FileSummaryItem",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("file_index", models.PositiveIntegerField()),
(
"directory_level",
models.CharField(blank=True, default="", max_length=300),
),
("file_name", models.CharField(max_length=255)),
("file_type", models.CharField(max_length=20)),
("relative_path", models.CharField(max_length=500)),
("storage_path", models.CharField(max_length=500)),
("page_count", models.IntegerField(blank=True, null=True)),
(
"statistics_status",
models.CharField(
choices=[
("success", "成功"),
("failed", "失败"),
("unsupported", "不支持"),
("uncertain", "不确定"),
("skipped", "跳过"),
],
default="skipped",
max_length=20,
),
),
("retry_count", models.PositiveIntegerField(default=0)),
("error_message", models.TextField(blank=True, default="")),
("created_at", models.DateTimeField(auto_now_add=True)),
("updated_at", models.DateTimeField(auto_now=True)),
(
"batch",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="items",
to="review_agent.filesummarybatch",
),
),
],
options={
"db_table": "ra_file_summary_item",
"ordering": ["file_index", "id"],
},
),
migrations.CreateModel(
name="WorkflowEvent",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("event_type", models.CharField(max_length=40)),
("payload", models.JSONField(default=dict)),
("created_at", models.DateTimeField(auto_now_add=True)),
(
"batch",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="events",
to="review_agent.filesummarybatch",
),
),
],
options={
"db_table": "ra_workflow_event",
"ordering": ["id"],
},
),
migrations.CreateModel(
name="WorkflowNodeRun",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("node_code", models.CharField(max_length=40)),
("node_name", models.CharField(max_length=80)),
(
"status",
models.CharField(
choices=[
("pending", "等待中"),
("running", "执行中"),
("retrying", "重试中"),
("success", "成功"),
("failed", "失败"),
("skipped", "跳过"),
],
default="pending",
max_length=20,
),
),
("progress", models.PositiveIntegerField(default=0)),
("message", models.TextField(blank=True, default="")),
("started_at", models.DateTimeField(blank=True, null=True)),
("finished_at", models.DateTimeField(blank=True, null=True)),
(
"batch",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="node_runs",
to="review_agent.filesummarybatch",
),
),
],
options={
"db_table": "ra_workflow_node_run",
},
),
migrations.AddIndex(
model_name="fileattachment",
index=models.Index(
fields=["conversation", "created_at"],
name="idx_ra_attachment_conv_created",
),
),
migrations.AddIndex(
model_name="fileattachment",
index=models.Index(
fields=["user", "created_at"], name="idx_ra_attachment_user_created"
),
),
migrations.AddIndex(
model_name="fileattachment",
index=models.Index(
fields=["conversation", "original_name", "is_active"],
name="idx_ra_attachment_active",
),
),
migrations.AddConstraint(
model_name="fileattachment",
constraint=models.UniqueConstraint(
fields=("conversation", "original_name", "version_no"),
name="uq_ra_attachment_conv_name_version",
),
),
migrations.AddIndex(
model_name="filesummarybatch",
index=models.Index(
fields=["conversation", "created_at"], name="idx_ra_batch_conv_created"
),
),
migrations.AddIndex(
model_name="filesummarybatch",
index=models.Index(
fields=["user", "created_at"], name="idx_ra_batch_user_created"
),
),
migrations.AddIndex(
model_name="filesummarybatch",
index=models.Index(
fields=["status", "created_at"], name="idx_ra_batch_status"
),
),
migrations.AddIndex(
model_name="exportedsummaryfile",
index=models.Index(
fields=["batch", "export_type"], name="idx_ra_export_batch_type"
),
),
migrations.AddIndex(
model_name="exportedsummaryfile",
index=models.Index(
fields=["batch", "created_at"], name="idx_ra_export_batch_created"
),
),
migrations.AddIndex(
model_name="filesummarybatchattachment",
index=models.Index(
fields=["batch", "created_at"], name="idx_ra_batch_attachment_batch"
),
),
migrations.AddIndex(
model_name="filesummarybatchattachment",
index=models.Index(fields=["attachment"], name="idx_ra_batch_attach_file"),
),
migrations.AddConstraint(
model_name="filesummarybatchattachment",
constraint=models.UniqueConstraint(
fields=("batch", "attachment"), name="uq_ra_batch_attachment"
),
),
migrations.AddIndex(
model_name="filesummaryitem",
index=models.Index(
fields=["batch", "file_index"], name="idx_ra_item_batch_index"
),
),
migrations.AddIndex(
model_name="filesummaryitem",
index=models.Index(
fields=["batch", "statistics_status"], name="idx_ra_item_batch_status"
),
),
migrations.AddIndex(
model_name="filesummaryitem",
index=models.Index(
fields=["batch", "file_type"], name="idx_ra_item_batch_type"
),
),
migrations.AddConstraint(
model_name="filesummaryitem",
constraint=models.UniqueConstraint(
fields=("batch", "relative_path"), name="uq_ra_item_batch_relative_path"
),
),
migrations.AddIndex(
model_name="workflowevent",
index=models.Index(fields=["batch", "id"], name="idx_ra_event_batch_id"),
),
migrations.AddIndex(
model_name="workflowevent",
index=models.Index(
fields=["batch", "created_at"], name="idx_ra_event_batch_created"
),
),
migrations.AddIndex(
model_name="workflownoderun",
index=models.Index(
fields=["batch", "status"], name="idx_ra_node_batch_status"
),
),
migrations.AddConstraint(
model_name="workflownoderun",
constraint=models.UniqueConstraint(
fields=("batch", "node_code"), name="uq_ra_node_batch_code"
),
),
]