代码提交
This commit is contained in:
1 parent
b101ee7fc9
commit
1938c80061
42 files changed
+5552
-278
No files matched your search
+61
@@ -0,0 +1,61 @@
|
||||
"""Create parallel_agent_tasks table.
|
||||
|
||||
Saved runs of the standalone parallel multi-agent panel (Vue embeddable
|
||||
component): task name + brief + agents snapshot + the resulting message list,
|
||||
bound per user. ``brief`` / ``agents`` / ``messages`` are LONGTEXT on MySQL
|
||||
(mirror ``roundtable_drafts`` headroom) and plain TEXT elsewhere — matching
|
||||
``PortableLongText``. ``create_all`` builds the table for brand-new DBs; this
|
||||
revision patches DBs that already exist.
|
||||
|
||||
Chained after ``20260608_04`` (chain stage_goals) so the revision graph stays
|
||||
single-headed — otherwise ``alembic upgrade head`` aborts with "multiple heads"
|
||||
and the startup auto-migrate silently falls back to the create_all schema.
|
||||
|
||||
Revision ID: 20260608_05
|
||||
Revises: 20260608_04
|
||||
Create Date: 2026-06-08
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
from sqlalchemy import inspect
|
||||
from sqlalchemy.dialects.mysql import LONGTEXT
|
||||
|
||||
|
||||
revision = "20260608_05"
|
||||
down_revision = "20260608_04"
|
||||
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("parallel_agent_tasks"):
|
||||
return
|
||||
long_text = LONGTEXT() if op.get_bind().dialect.name == "mysql" else sa.Text()
|
||||
op.create_table(
|
||||
"parallel_agent_tasks",
|
||||
sa.Column("id", sa.String(length=64), primary_key=True, nullable=False),
|
||||
sa.Column("user_id", sa.String(length=64), nullable=False),
|
||||
sa.Column("title", sa.String(length=512), nullable=False, server_default=""),
|
||||
sa.Column("brief", long_text, nullable=True),
|
||||
sa.Column("agents", long_text, nullable=True),
|
||||
sa.Column("messages", long_text, nullable=True),
|
||||
sa.Column("created_at", sa.DateTime(), nullable=False),
|
||||
sa.Column("updated_at", sa.DateTime(), nullable=False),
|
||||
)
|
||||
op.create_index(
|
||||
"ix_parallel_agent_tasks_user_id", "parallel_agent_tasks", ["user_id"]
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
if _has_table("parallel_agent_tasks"):
|
||||
op.drop_index("ix_parallel_agent_tasks_user_id", table_name="parallel_agent_tasks")
|
||||
op.drop_table("parallel_agent_tasks")
|
||||
Reference in new issue
Block a user