Files
shaguabijia-app-server/alembic/versions/device_kill_alert_pending.py
T
陈世睿 2162056008 feat(device): 无障碍保护存活心跳检测 + 掉线后置检测(pull)
- device 表 + 心跳/注册/liveness 查询/ack 端点 + heartbeat_monitor_worker
  (扫描超时设备置 kill_alert_pending, 客户端进 App 拉取弹自启动引导)
- 本期只做 pull 后置检测, 不接推送(不含 jpush)
- 迁移: device_table → device_kill_alert_pending(接 main head ceb286289426, 线性单 head)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-21 11:49:54 +08:00

40 lines
1.3 KiB
Python

"""device.kill_alert_pending (无障碍掉线「后置检测」待提醒标记)
Revision ID: device_kill_alert_pending
Revises: device_liveness_table
Create Date: 2026-06-19
后置检测 pull 版(spec/accessibility-liveness-pull-prompt.md):worker 检出心跳掉线即置此标记,
客户端下次进 App 拉取到 → 弹「开启自启动」引导,交互后 ack 清回。与 liveness_state 解耦,故单列。
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision: str = 'device_kill_alert_pending'
down_revision: Union[str, Sequence[str], None] = 'device_liveness_table'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
# server_default=sa.false() 跨方言: SQLite 渲染 0 / PG 渲染 false(别用 sa.text("0"),PG 布尔严格会报错),
# 给存量行回填 False。
with op.batch_alter_table('device', schema=None) as batch_op:
batch_op.add_column(
sa.Column(
'kill_alert_pending',
sa.Boolean(),
nullable=False,
server_default=sa.false(),
)
)
def downgrade() -> None:
with op.batch_alter_table('device', schema=None) as batch_op:
batch_op.drop_column('kill_alert_pending')