Some checks failed
Deploy / deploy (push) Has been cancelled
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>
96 lines
2.5 KiB
Markdown
96 lines
2.5 KiB
Markdown
# 数据库表名规范化方案
|
||
|
||
## 现状分析
|
||
|
||
根据分析,当前数据库中存在以下前缀的表:
|
||
|
||
### 1. 旧版本表(c_前缀)
|
||
- `c_tg_account` - TG账号
|
||
- `c_firstname` - 名字
|
||
- `c_lastname` - 姓氏
|
||
- `c_group` - 群组
|
||
- `c_message` - 消息
|
||
- `c_config` - 配置
|
||
- `c_script` - 脚本
|
||
- `c_script_article` - 脚本文章
|
||
- `c_script_project` - 脚本项目
|
||
- `c_script_task` - 脚本任务
|
||
|
||
### 2. 当前版本表(tg_前缀)
|
||
- `tg_account` - TG账号
|
||
- `tg_firstname` - 名字
|
||
- `tg_lastname` - 姓氏
|
||
- `tg_group` - 群组
|
||
- `tg_message` - 消息
|
||
- `tg_config` - 配置
|
||
- `tg_script` - 脚本
|
||
- `tg_script_article` - 脚本文章
|
||
- `tg_script_project` - 脚本项目
|
||
- `tg_script_task` - 脚本任务
|
||
- `tg_dc` - 数据中心
|
||
- `tg_telegram_users` - Telegram用户
|
||
|
||
### 3. 其他前缀表(m_前缀)
|
||
- `m_tg_account` - TG账号(代码中发现)
|
||
|
||
## 规范化方案
|
||
|
||
### 核心原则
|
||
1. 统一表名规范,去除冗余前缀
|
||
2. 采用简洁明了的英文命名
|
||
3. 保持业务逻辑清晰的分组
|
||
|
||
### 新的命名规范
|
||
|
||
#### 1. 账号管理模块
|
||
- `tg_account` → `accounts` (账号表)
|
||
- `tg_telegram_users` → `telegram_users` (Telegram用户表)
|
||
|
||
#### 2. 名称管理模块
|
||
- `tg_firstname` → `firstnames` (名字表)
|
||
- `tg_lastname` → `lastnames` (姓氏表)
|
||
|
||
#### 3. 群组管理模块
|
||
- `tg_group` → `groups` (群组表)
|
||
|
||
#### 4. 消息管理模块
|
||
- `tg_message` → `messages` (消息表)
|
||
|
||
#### 5. 脚本管理模块
|
||
- `tg_script` → `scripts` (脚本表)
|
||
- `tg_script_article` → `script_articles` (脚本文章表)
|
||
- `tg_script_project` → `script_projects` (脚本项目表)
|
||
- `tg_script_task` → `script_tasks` (脚本任务表)
|
||
|
||
#### 6. 系统配置模块
|
||
- `tg_config` → `configs` (配置表)
|
||
- `tg_dc` → `data_centers` (数据中心表)
|
||
|
||
## 迁移计划
|
||
|
||
### 阶段1:表重命名
|
||
1. 备份当前数据库
|
||
2. 创建重命名SQL脚本
|
||
3. 执行表重命名操作
|
||
|
||
### 阶段2:清理旧表
|
||
1. 确认新表数据完整性
|
||
2. 删除c_前缀的旧表
|
||
3. 删除m_前缀的重复表
|
||
|
||
### 阶段3:代码更新
|
||
1. 更新后端API代码中的表名引用
|
||
2. 更新前端接口调用
|
||
3. 测试功能完整性
|
||
|
||
## 优势
|
||
1. **简洁性**:去除冗余前缀,表名更加简洁
|
||
2. **一致性**:统一命名规范,便于维护
|
||
3. **可读性**:表名直观反映业务含义
|
||
4. **扩展性**:为未来模块扩展提供良好基础
|
||
|
||
## 注意事项
|
||
1. 在执行重命名前务必备份数据库
|
||
2. 需要同步更新所有相关代码
|
||
3. 建议在测试环境先执行完整流程
|
||
4. 考虑数据库约束和索引的更新 |