Files
telegram-management-system/database/scripts/update_table_references.sh
你的用户名 237c7802e5
Some checks failed
Deploy / deploy (push) Has been cancelled
Initial commit: Telegram Management System
Full-stack web application for Telegram management
- Frontend: Vue 3 + Vben Admin
- Backend: NestJS
- Features: User management, group broadcast, statistics

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-04 15:37:50 +08:00

52 lines
1.9 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# 批量更新代码中的表名引用脚本
PROJECT_ROOT="/Users/hahaha/telegram-management-system"
echo "开始更新代码中的表名引用..."
# 查找所有需要更新的文件排除node_modules和database目录
find $PROJECT_ROOT -name "*.js" -type f ! -path "*/node_modules/*" ! -path "*/database/*" | while read file; do
# 检查文件是否包含旧表名
if grep -q "tg_account\|tg_group\|tg_message\|tg_config\|tg_script\|m_tg_account\|c_tg_account" "$file"; then
echo "更新文件: $file"
# 创建备份
cp "$file" "$file.bak"
# 执行替换
sed -i.tmp "
s/m_tg_account/accounts/g
s/c_tg_account/accounts/g
s/tg_account/accounts/g
s/tg_group/chat_groups/g
s/tg_message/messages/g
s/tg_config/configs/g
s/tg_script/scripts/g
s/tg_firstname/firstnames/g
s/tg_lastname/lastnames/g
s/tg_dc/data_centers/g
s/tg_telegram_users/telegram_users/g
s/tg_account_health/account_health/g
s/tg_account_pool/account_pools/g
s/tg_account_usage/account_usages/g
s/tg_account_usage_log/account_usage_logs/g
s/tg_group_listener/group_listeners/g
s/tg_group_task/group_tasks/g
s/tg_login_code_log/login_code_logs/g
s/tg_register_log/register_logs/g
s/tg_pull_member_log/pull_member_logs/g
s/tg_pull_member_task/pull_member_tasks/g
" "$file"
# 删除临时文件
rm "$file.tmp" 2>/dev/null
echo "✅ 已更新: $file"
fi
done
echo "批量更新完成!"
echo "注意:原文件已备份为 .bak 扩展名"
echo "如需回滚,请运行: find $PROJECT_ROOT -name '*.bak' -exec sh -c 'mv \"\$1\" \"\${1%.bak}\"' _ {} \;"