代码修改

This commit is contained in:
董宏凯 committed 2026-06-05 21:16:35 +08:00
1 parent 99aa064e6c
commit 6d5325d444
6 files changed
+90 -15

No files matched your search

@@ -7,7 +7,7 @@ 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
Revision ID: 20260604_02
Revises: 20260603_01
Create Date: 2026-06-04
"""
@@ -20,7 +20,7 @@ from sqlalchemy import inspect
from sqlalchemy.dialects.mysql import LONGTEXT
revision = "20260604_01"
revision = "20260604_02"
down_revision = "20260603_01"
branch_labels = None
depends_on = None
@@ -18,7 +18,7 @@ from sqlalchemy.dialects.mysql import LONGTEXT
revision = "20260605_01"
down_revision = "20260604_01"
down_revision = "20260604_02"
branch_labels = None
depends_on = None
@@ -0,0 +1,47 @@
"""Add ``agent_id`` to ``user_custom_prompts`` when the parallel branch was skipped.
Some deployments reached ``20260606_01`` via the roundtable-jobs migration branch
(``20260603_01`` → ``20260604_01`` jobs → …) without running the sibling branch
that adds ``agent_id`` (``20260603_02``). This idempotent fixup applies the
missing column for those DBs.
Revision ID: 20260607_01
Revises: 20260606_01
Create Date: 2026-06-07
"""
from __future__ import annotations
import sqlalchemy as sa
from alembic import op
from sqlalchemy import inspect
revision = "20260607_01"
down_revision = "20260606_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 _has_column(table_name: str, column_name: str) -> bool:
inspector = inspect(op.get_bind())
return any(col["name"] == column_name for col in inspector.get_columns(table_name))
def upgrade() -> None:
if not _has_table("user_custom_prompts"):
return
if not _has_column("user_custom_prompts", "agent_id"):
op.add_column("user_custom_prompts", sa.Column("agent_id", sa.String(64), nullable=True))
op.create_index("ix_user_custom_prompts_agent_id", "user_custom_prompts", ["agent_id"])
def downgrade() -> None:
if _has_table("user_custom_prompts") and _has_column("user_custom_prompts", "agent_id"):
op.drop_index("ix_user_custom_prompts_agent_id", table_name="user_custom_prompts")
op.drop_column("user_custom_prompts", "agent_id")
@@ -0,0 +1,22 @@
"""Merge parallel migration branches (agent_pins + roundtable jobs fixup).
Revision ID: 20260607_02
Revises: 20260604_01, 20260607_01
Create Date: 2026-06-07
"""
from __future__ import annotations
revision = "20260607_02"
down_revision = ("20260604_01", "20260607_01")
branch_labels = None
depends_on = None
def upgrade() -> None:
pass
def downgrade() -> None:
pass