feat(fulfillment): 支持共享账号操作并完善时间线

This commit is contained in:
yml
2026-11-18 22:32:45 +08:00
parent 86b586b96d
commit ddead2284d
23 changed files with 538 additions and 15 deletions
@@ -0,0 +1,59 @@
"""关联斗鱼任务与直播履约任务上下文。"""
from __future__ import annotations
import sqlalchemy as sa
from alembic import op
revision: str = "20261118_0096"
down_revision: str | None = "20261118_0095"
branch_labels: str | None = None
depends_on: str | None = None
TABLE = "douyu_tasks"
COLUMN = "platform_task_id"
INDEX = "ix_douyu_tasks_platform_task_id"
def _column_exists() -> bool:
return bool(
op.get_bind()
.execute(
sa.text(
"SELECT COUNT(*) FROM information_schema.columns "
"WHERE table_schema = DATABASE() "
"AND table_name = :table AND column_name = :column"
),
{"table": TABLE, "column": COLUMN},
)
.scalar()
)
def _index_exists() -> bool:
return bool(
op.get_bind()
.execute(
sa.text(
"SELECT COUNT(*) FROM information_schema.statistics "
"WHERE table_schema = DATABASE() "
"AND table_name = :table AND index_name = :index"
),
{"table": TABLE, "index": INDEX},
)
.scalar()
)
def upgrade() -> None:
if not _column_exists():
op.add_column(TABLE, sa.Column(COLUMN, sa.BigInteger(), nullable=True))
if not _index_exists():
op.create_index(INDEX, TABLE, [COLUMN])
def downgrade() -> None:
if _index_exists():
op.drop_index(INDEX, table_name=TABLE)
if _column_exists():
op.drop_column(TABLE, COLUMN)