```
feat: 添加飞书用户模块和订阅功能支持 - 新增feishu_users模块用于处理飞书用户身份验证和权限管理 - 新增subscriptions模块用于处理订阅相关功能 - 新增personalization模块用于个性化服务 - 在alembic迁移配置中注册新的模型模块 - 在API路由器中添加feishu_users和subscriptions路由 - 实现事件调度服务的改进,包括错误处理和状态更新优化 - 添加飞书命令处理的权限检查机制 - 实现飞书应用票据事件处理 - 改进审计日志记录功能 ```
This commit is contained in:
51
alembic/versions/202607260001_v3_runtime_reliability.py
Normal file
51
alembic/versions/202607260001_v3_runtime_reliability.py
Normal file
@@ -0,0 +1,51 @@
|
||||
"""Harden V3 heartbeat identity and concurrent updates.
|
||||
|
||||
Revision ID: 202607260001
|
||||
Revises: 202607150001
|
||||
Create Date: 2026-07-26
|
||||
"""
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
revision = "202607260001"
|
||||
down_revision = "202607150001"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
HEARTBEAT_TABLE = "system_heartbeats"
|
||||
HEARTBEAT_IDENTITY_CONSTRAINT = "uq_system_heartbeat_component_instance"
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
op.execute(
|
||||
sa.text(
|
||||
"""
|
||||
DELETE FROM system_heartbeats
|
||||
WHERE id IN (
|
||||
SELECT id
|
||||
FROM (
|
||||
SELECT
|
||||
id,
|
||||
ROW_NUMBER() OVER (
|
||||
PARTITION BY component, instance_id
|
||||
ORDER BY last_seen_at DESC, id DESC
|
||||
) AS duplicate_rank
|
||||
FROM system_heartbeats
|
||||
) ranked
|
||||
WHERE duplicate_rank > 1
|
||||
)
|
||||
"""
|
||||
)
|
||||
)
|
||||
with op.batch_alter_table(HEARTBEAT_TABLE) as batch_op:
|
||||
batch_op.create_unique_constraint(
|
||||
HEARTBEAT_IDENTITY_CONSTRAINT,
|
||||
["component", "instance_id"],
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
with op.batch_alter_table(HEARTBEAT_TABLE) as batch_op:
|
||||
batch_op.drop_constraint(HEARTBEAT_IDENTITY_CONSTRAINT, type_="unique")
|
||||
Reference in New Issue
Block a user