Files
你的用户名 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

79 lines
1.9 KiB
Markdown
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.

# Database 文件夹说明
这个文件夹专门用于管理数据库相关的文件和操作。
## 文件夹结构
```
database/
├── backups/ # 数据库备份文件
├── migrations/ # 数据库迁移脚本
├── scripts/ # 数据库管理脚本
└── schemas/ # 数据库结构和文档
```
## 主要功能
### 1. 数据库备份 (backups/)
- 存储数据库备份文件
- 自动清理旧备份保留7天
- 支持压缩存储
### 2. 数据库迁移 (migrations/)
- 包含所有历史迁移脚本
- 数据迁移和表结构变更记录
### 3. 管理脚本 (scripts/)
- `backup_database.sh` - 数据库备份脚本
- `normalize_table_names.sql` - 表名规范化脚本
- `rollback_table_names.sql` - 表名回滚脚本
### 4. 数据库文档 (schemas/)
- `table_normalization_plan.md` - 表名规范化方案文档
## 使用方法
### 备份数据库
```bash
cd database/scripts
./backup_database.sh
```
### 执行表名规范化
⚠️ **执行前务必备份数据库!**
```bash
# 1. 先备份
./backup_database.sh
# 2. 执行规范化
mysql -u root -p tg_manage < normalize_table_names.sql
# 3. 如需回滚
mysql -u root -p tg_manage < rollback_table_names.sql
```
## 表名规范化
### 当前状态
- 使用 `tg_` 前缀的表名
- 存在一些 `c_``m_` 前缀的旧表
### 规范化后
- 去除冗余前缀,使用简洁的英文表名
- 例如:`tg_account``accounts`
详细规划请查看 `schemas/table_normalization_plan.md`
## 注意事项
1. **备份第一**: 任何数据库操作前都要先备份
2. **测试环境**: 建议先在测试环境执行
3. **代码同步**: 表名修改后需要同步更新代码
4. **权限管理**: 确保数据库用户有足够权限执行操作
## 维护
- 备份文件自动保留7天
- 定期检查磁盘空间
- 监控数据库性能和完整性