b2c20ec43d
- 新增微信告警服务(wechat_service)和告警任务(alert_tasks) - 新增 WebSocket 实时推送端点 - 新增监控管理模块(monitor) - 增强统计仪表板:趋势图、区域分布、光功率历史 - 设备管理:添加坐标信息、标签系统、复合索引优化 - 前端:重构Dashboard/Charts页面,新增业务组件 - 新增5个数据库迁移(坐标、复合索引、标签、光功率历史、显示名) - 更新部署配置和脚本 - 新增测试框架基础结构
30 lines
1.2 KiB
Python
30 lines
1.2 KiB
Python
"""add composite indexes for performance
|
|
|
|
Revision ID: j0k1l2m3n4o5
|
|
Revises: i9j0k1l2m3n4
|
|
Create Date: 2026-06-02 15:00:00.000000
|
|
|
|
"""
|
|
from typing import Sequence, Union
|
|
from alembic import op
|
|
|
|
revision: str = 'j0k1l2m3n4o5'
|
|
down_revision: Union[str, None] = 'i9j0k1l2m3n4'
|
|
branch_labels: Union[str, Sequence[str], None] = None
|
|
depends_on: Union[str, Sequence[str], None] = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
# FK 索引 — 每次状态检查都要按 OLT 查询设备
|
|
op.create_index('ix_onu_devices_olt_id', 'onu_devices', ['olt_id'])
|
|
# 复合索引 — Dashboard 按区域+学校聚合
|
|
op.create_index('ix_onu_devices_region_school', 'onu_devices', ['region', 'school_name'])
|
|
# FK 索引 — DeviceStatusHistory 按设备查最新状态(最频繁的查询)
|
|
op.create_index('ix_device_status_history_onu_device_id_checked', 'device_status_history', ['onu_device_id', 'checked_at'])
|
|
|
|
|
|
def downgrade() -> None:
|
|
op.drop_index('ix_device_status_history_onu_device_id_checked', table_name='device_status_history')
|
|
op.drop_index('ix_onu_devices_region_school', table_name='onu_devices')
|
|
op.drop_index('ix_onu_devices_olt_id', table_name='onu_devices')
|