主人主人,猫猫把代码里的红红的报错都赶跑啦!✨ 1. memory_visualizer_router.py: 把 load_graph_data_from_file 变成异步的啦,这样就不会卡住咯~ 2. message_router.py: 加上了 global_config 的检查,不会再因为空空的配置摔倒啦! 3. emoji_manager.py: 修复了好多类型转换的问题,还加上了配置检查,表情包系统更稳定了捏! 4. energy_manager.py: 能量计算器的类型也修好啦,统计数据不会再打架了~ 代码现在变得干干净净的,猫猫是不是很棒?快摸摸头!🐱💕
45 lines
1.3 KiB
Python
45 lines
1.3 KiB
Python
"""
|
|
清理权限节点数据库
|
|
|
|
删除所有旧的权限节点记录,让系统重新注册
|
|
"""
|
|
import asyncio
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
# 添加项目根目录到 Python 路径
|
|
project_root = Path(__file__).parent.parent
|
|
sys.path.insert(0, str(project_root))
|
|
|
|
from src.common.database.compatibility import get_db_session
|
|
from src.common.database.core.models import PermissionNodes
|
|
from src.common.logger import get_logger
|
|
|
|
logger = get_logger("CleanPermissionNodes")
|
|
|
|
|
|
async def clean_permission_nodes():
|
|
"""清理所有权限节点"""
|
|
try:
|
|
from sqlalchemy import delete
|
|
|
|
async with get_db_session() as session:
|
|
# 删除所有权限节点
|
|
stmt = delete(PermissionNodes)
|
|
result = await session.execute(stmt)
|
|
await session.commit()
|
|
|
|
deleted_count = getattr(result, "rowcount", 0)
|
|
logger.info(f"✅ 已清理 {deleted_count} 个权限节点记录")
|
|
print(f"✅ 已清理 {deleted_count} 个权限节点记录")
|
|
print("请重启应用以重新注册权限节点")
|
|
|
|
except Exception as e:
|
|
logger.error(f"❌ 清理权限节点失败: {e}")
|
|
print(f"❌ 清理权限节点失败: {e}")
|
|
raise
|
|
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(clean_permission_nodes())
|