Files
aiagent/backend/alembic/versions/006_add_execution_parent_depth.py
renjianbo 0608161c82 feat: 完善企业场景多线路由与执行稳定性
补齐平台模板与场景 DSL、预算控制、执行看板和企业场景脚本,增强 Windows 启动/迁移与前端代理和聊天会话记忆,修复执行创建阶段 500 与异步链路排障体验。

Made-with: Cursor
2026-04-09 21:58:53 +08:00

50 lines
1.5 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""add execution parent/depth columns
Revision ID: 006_add_execution_parent_depth
Revises: 005_persistent_user_memory
Create Date: 2026-04-08
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects.mysql import CHAR
revision = "006_add_execution_parent_depth"
down_revision = "005_persistent_user_memory"
branch_labels = None
depends_on = None
def upgrade() -> None:
op.add_column(
"executions",
sa.Column("parent_execution_id", CHAR(36), nullable=True, comment="父执行ID"),
)
op.add_column(
"executions",
sa.Column("depth", sa.Integer(), nullable=False, server_default="0", comment="执行深度根为0"),
)
op.create_foreign_key(
"fk_executions_parent_execution_id",
"executions",
"executions",
["parent_execution_id"],
["id"],
)
op.create_index(
"ix_executions_parent_execution_id",
"executions",
["parent_execution_id"],
unique=False,
)
op.create_index("ix_executions_depth", "executions", ["depth"], unique=False)
op.alter_column("executions", "depth", server_default=None)
def downgrade() -> None:
op.drop_index("ix_executions_depth", table_name="executions")
op.drop_index("ix_executions_parent_execution_id", table_name="executions")
op.drop_constraint("fk_executions_parent_execution_id", "executions", type_="foreignkey")
op.drop_column("executions", "depth")
op.drop_column("executions", "parent_execution_id")