-- 数据库表名规范化回滚脚本
-- 用于恢复到原始表名

USE tg_manage;

-- 禁用外键检查
SET FOREIGN_KEY_CHECKS = 0;

-- 回滚表名到原始tg_前缀
RENAME TABLE accounts TO tg_account;
RENAME TABLE firstnames TO tg_firstname;
RENAME TABLE lastnames TO tg_lastname;
RENAME TABLE chat_groups TO tg_group;
RENAME TABLE messages TO tg_message;
RENAME TABLE configs TO tg_config;
RENAME TABLE scripts TO tg_script;
RENAME TABLE script_articles TO tg_script_article;
RENAME TABLE script_projects TO tg_script_project;
RENAME TABLE script_tasks TO tg_script_task;
RENAME TABLE data_centers TO tg_dc;
RENAME TABLE telegram_users TO tg_telegram_users;

-- 重新启用外键检查
SET FOREIGN_KEY_CHECKS = 1;

-- 验证回滚结果
SELECT 'Table names rolled back successfully!' as status;

-- 显示所有表
SHOW TABLES;