Merge origin/master into ji
This commit is contained in:
commit
e96cc97462
54 files changed
+4900
-334
No files matched your search
+68
@@ -0,0 +1,68 @@
|
||||
"""Create roundtable_jobs table.
|
||||
|
||||
Backend background-orchestration jobs for the roundtable-planning Step 2「后台挂起」
|
||||
feature: one row per server-side run of the leader→dispatch→consensus→report
|
||||
pipeline. Big JSON columns (dispatch_chain / thread_ids / chain) are LONGTEXT on
|
||||
MySQL (can exceed the 64 KB TEXT cap) and plain TEXT elsewhere — matching
|
||||
``PortableLongText`` on ``RoundtableJobRow``. ``create_all`` adds the table for
|
||||
brand-new DBs; this revision creates it on DBs that predate it.
|
||||
|
||||
Revision ID: 20260604_01
|
||||
Revises: 20260603_01
|
||||
Create Date: 2026-06-04
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
from sqlalchemy import inspect
|
||||
from sqlalchemy.dialects.mysql import LONGTEXT
|
||||
|
||||
|
||||
revision = "20260604_01"
|
||||
down_revision = "20260603_01"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def _has_table(table_name: str) -> bool:
|
||||
inspector = inspect(op.get_bind())
|
||||
return table_name in inspector.get_table_names()
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
if _has_table("roundtable_jobs"):
|
||||
return
|
||||
|
||||
long_text = LONGTEXT() if op.get_bind().dialect.name == "mysql" else sa.Text()
|
||||
|
||||
op.create_table(
|
||||
"roundtable_jobs",
|
||||
sa.Column("id", sa.String(64), primary_key=True),
|
||||
sa.Column("draft_id", sa.String(64), nullable=True),
|
||||
sa.Column("user_id", sa.String(64), nullable=True),
|
||||
sa.Column("status", sa.String(32), nullable=False, server_default="queued"),
|
||||
sa.Column("phase", sa.String(32), nullable=False, server_default="initializing"),
|
||||
sa.Column("cycle", sa.Integer, nullable=False, server_default="0"),
|
||||
sa.Column("dispatch_chain", long_text, nullable=True),
|
||||
sa.Column("active_agent_id", sa.String(128), nullable=True),
|
||||
sa.Column("consensus_percentage", sa.Integer, nullable=False, server_default="0"),
|
||||
sa.Column("pending_clarification", sa.Text, nullable=True),
|
||||
sa.Column("thread_ids", long_text, nullable=True),
|
||||
sa.Column("coordinator_name", sa.String(128), nullable=True),
|
||||
sa.Column("orchestration_mode", sa.String(16), nullable=False, server_default="recommend"),
|
||||
sa.Column("chain", long_text, nullable=True),
|
||||
sa.Column("error", sa.Text, nullable=True),
|
||||
sa.Column("created_at", sa.DateTime(timezone=True), nullable=False),
|
||||
sa.Column("updated_at", sa.DateTime(timezone=True), nullable=False),
|
||||
)
|
||||
op.create_index("ix_roundtable_jobs_draft_id", "roundtable_jobs", ["draft_id"])
|
||||
op.create_index("ix_roundtable_jobs_user_id", "roundtable_jobs", ["user_id"])
|
||||
op.create_index("ix_roundtable_jobs_status", "roundtable_jobs", ["status"])
|
||||
op.create_index("ix_roundtable_jobs_updated_at", "roundtable_jobs", ["updated_at"])
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
if _has_table("roundtable_jobs"):
|
||||
op.drop_table("roundtable_jobs")
|
||||
Reference in new issue
Block a user