From 3f3e39e4d520fac4edc3a6d113d2eb55c5866f77 Mon Sep 17 00:00:00 2001 From: ThearchyHelios Date: Sun, 18 Oct 2026 15:25:13 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BC=96=E6=8E=92=E5=AE=8C=E5=96=84=E7=AC=AC?= =?UTF-8?q?=201=20=E6=B3=A2=E9=AA=A8=E6=9E=B6=EF=BC=9A=E5=AE=9A=E6=97=B6?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E5=8A=A0=E8=A7=A6=E5=8F=91=E6=96=B9=E5=BC=8F?= =?UTF-8?q?=EF=BC=88trigger=5Fkind=EF=BC=9Acron=20|=20event=EF=BC=8Ctrigge?= =?UTF-8?q?r=20=E5=86=99=E4=BA=8B=E4=BB=B6=E7=A7=8D=E7=B1=BB=E5=92=8C?= =?UTF-8?q?=E5=AF=B9=E8=B1=A1=EF=BC=89=E4=B8=A4=E5=88=97=E4=B8=8E=E8=BF=81?= =?UTF-8?q?=E7=A7=BB=EF=BC=8C=E5=AD=98=E9=87=8F=E8=A1=8C=E9=83=BD=E6=98=AF?= =?UTF-8?q?=20cron=EF=BC=88docs/design/orchestration-round/00-=E6=80=BB?= =?UTF-8?q?=E6=96=B9=E6=A1=88.md=20=C2=A74=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/db/base.py | 3 +++ backend/app/db/models.py | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/backend/app/db/base.py b/backend/app/db/base.py index fe940284..24a40182 100644 --- a/backend/app/db/base.py +++ b/backend/app/db/base.py @@ -245,6 +245,9 @@ _COLUMN_MIGRATIONS: list[tuple[str, str, str]] = [ ("schedules", "target_kind", "VARCHAR(20) DEFAULT 'workflow'"), ("schedules", "target_id", "VARCHAR(32)"), ("schedule_fires", "eval_run_id", "VARCHAR(32)"), + # 编排完善(docs/design/orchestration-round/00-总方案.md §4):定时任务的触发方式。存量行都是 cron + ("schedules", "trigger_kind", "VARCHAR(20) DEFAULT 'cron'"), + ("schedules", "trigger", "JSON"), # 第 2 波:服务账号(users.kind);剖析上传表格源时的快照 ("users", "kind", "VARCHAR(20) DEFAULT 'person'"), ("catalog_profile_tasks", "snapshot_id", "VARCHAR(32)"), diff --git a/backend/app/db/models.py b/backend/app/db/models.py index b570945c..9565cecd 100644 --- a/backend/app/db/models.py +++ b/backend/app/db/models.py @@ -988,6 +988,11 @@ class Schedule(Base, TimestampMixin): target_kind: Mapped[str] = mapped_column(String(20), default="workflow") # 目标的 id:workflow 时同 workflow_id;其余两种是题集 id、数据源 id target_id: Mapped[str | None] = mapped_column(String(32), default=None, index=True) + # 怎么触发(docs/design/orchestration-round/00-总方案.md §4):cron 按 cron 表达式到点触发(加这一列之前的都是); + # event 由事件触发,trigger 写事件种类和对象(table.version / workflow.finished / source.changed,见 scheduler 的说明)。 + # event 时 cron 存空串(老表的非空约束),下一次触发时间为空 + trigger_kind: Mapped[str] = mapped_column(String(20), default="cron") + trigger: Mapped[dict[str, Any]] = mapped_column(default=dict) # 非空(老表的约束,只加不改的迁移放宽不了):目标不是工作流时存空串,读写都经 scheduler/service 里的一处封装 workflow_id: Mapped[str] = mapped_column(String(32), index=True) # 保存时的工作流名。工作流还在时接口给它现在的名字,删掉之后才用这一份