wujie应用联调

This commit is contained in:
董宏凯 committed 2026-06-11 17:11:28 +08:00
1 parent 0784f30e23
commit f3ca996116
35 files changed
+1590 -334

No files matched your search

@@ -0,0 +1,49 @@
"""Add task_id column to roundtable_drafts.
External task id (passed by the wujie-embedded roundtable drawer). When set, the
draft is keyed/shared by ``task_id`` and is no longer partitioned by ``user_id``
(read/write/delete ownership checks are relaxed for task-bound drafts — see
``sql.py``); when NULL the original per-user isolation is preserved.
``create_all`` adds the column for brand-new DBs; this revision patches DBs that
already have the table.
Revision ID: 20260611_01
Revises: 20260609_02
Create Date: 2026-06-11
"""
from __future__ import annotations
import sqlalchemy as sa
from alembic import op
from sqlalchemy import inspect
revision = "20260611_01"
down_revision = "20260609_02"
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:
if not _has_table(table_name):
return False
inspector = inspect(op.get_bind())
return any(col["name"] == column_name for col in inspector.get_columns(table_name))
def upgrade() -> None:
if _has_table("roundtable_drafts") and not _has_column("roundtable_drafts", "task_id"):
op.add_column("roundtable_drafts", sa.Column("task_id", sa.String(128), nullable=True))
op.create_index("ix_roundtable_drafts_task_id", "roundtable_drafts", ["task_id"])
def downgrade() -> None:
if _has_column("roundtable_drafts", "task_id"):
op.drop_index("ix_roundtable_drafts_task_id", table_name="roundtable_drafts")
op.drop_column("roundtable_drafts", "task_id")