43 lines
1.3 KiB
Python
43 lines
1.3 KiB
Python
"""tasks.channel 列(渠道来源:web / wechat).
|
|
|
|
Revision ID: 0013
|
|
Revises: 0012
|
|
Create Date: 2026-06-24
|
|
|
|
给 tasks 加 channel 列,标记任务来源渠道:
|
|
- web = 网页端常规任务(默认)
|
|
- wechat = 微信 ClawBot 常驻对话(每用户一条)
|
|
|
|
只加列、不动现有数据;server_default='web' 让历史行自动回填为 web。建表后把
|
|
现网已存在的微信常驻 task(description = '(微信 ClawBot 对话)')backfill 成
|
|
'wechat',让置顶 / 徽章逻辑对存量数据立即生效。
|
|
|
|
前端据 channel 给微信任务打徽章并后端强制置顶(列表查询排序前置 pin 表达式)。
|
|
"""
|
|
from typing import Sequence, Union
|
|
|
|
import sqlalchemy as sa
|
|
from alembic import op
|
|
|
|
|
|
revision: str = "0013"
|
|
down_revision: Union[str, None] = "0012"
|
|
branch_labels: Union[str, Sequence[str], None] = None
|
|
depends_on: Union[str, Sequence[str], None] = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
op.add_column(
|
|
"tasks",
|
|
sa.Column("channel", sa.Text(), nullable=False, server_default="web"),
|
|
)
|
|
# backfill 存量微信常驻 task —— 用建 task 时写死的 description 作标记。
|
|
op.execute(
|
|
"UPDATE tasks SET channel = 'wechat' "
|
|
"WHERE description = '(微信 ClawBot 对话)'"
|
|
)
|
|
|
|
|
|
def downgrade() -> None:
|
|
op.drop_column("tasks", "channel")
|