Files
user-system/docs/archive/migration/MIGRATION_CHECKLIST.md

485 lines
11 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.
# 项目迁移检查清单
## ⚠️ 重要提醒
在删除C盘旧文件之前请完成以下所有检查
---
## ✅ 迁移验证检查
### 1. 文件完整性检查
- [ ] 检查关键文件是否存在
```powershell
Test-Path D:\project\go.mod
Test-Path D:\project\README.md
Test-Path D:\project\cmd\server\main.go
Test-Path D:\project\configs\config.yaml
Test-Path D:\project\docker-compose.yml
```
预期结果: 全部返回 `True`
- [ ] 检查关键目录是否存在
```powershell
Test-Path D:\project\cmd
Test-Path D:\project\internal
Test-Path D:\project\configs
Test-Path D:\project\docs
Test-Path D:\project\migrations
Test-Path D:\project\deployment
```
预期结果: 全部返回 `True`
### 2. 文件数量验证
- [ ] 统计D盘项目文件数
```powershell
(Get-ChildItem -Path D:\project -Recurse -File | Measure-Object).Count
```
预期结果: 应该 >= 117
### 3. 文件大小验证
- [ ] 计算项目总大小
```powershell
[math]::Round((Get-ChildItem -Path D:\project -Recurse | Measure-Object -Property Length -Sum).Sum / 1MB, 2)
```
预期结果: 应该接近 0.85 MB
---
## 🔧 环境配置检查
### 4. Go环境安装
- [ ] 检查Go是否已安装
```powershell
go version
```
预期结果: 显示版本号 (如: go version go1.23.x windows/amd64)
- [ ] 如果未安装下载并安装Go
- 下载地址: https://golang.org/dl/
- 选择: `go1.23.x.windows-amd64.msi`
- 运行安装程序
- 重启命令行窗口
- [ ] 验证Go环境变量
```powershell
go env
```
预期结果: 显示完整的Go环境配置
### 5. Go模块验证
- [ ] 切换到项目目录
```powershell
cd D:\project
```
- [ ] 验证Go模块
```powershell
go mod verify
```
预期结果: 显示 "all modules verified"
- [ ] 下载依赖
```powershell
go mod download
```
预期结果: 无错误
### 6. 编译验证
- [ ] 尝试编译项目
```powershell
go build ./cmd/server
```
预期结果: 生成 `server.exe` 文件
- [ ] 检查生成的可执行文件
```powershell
Test-Path D:\project\server.exe
```
预期结果: 返回 `True`
---
## 🚀 运行测试检查
### 7. 启动项目
- [ ] 运行项目(开发模式)
```powershell
go run cmd/server/main.go
```
预期结果: 服务器启动,监听 8080 端口
**成功标志**:
- 看到 "Server started on port 8080"
- 看到 "Database connected"
- 无错误日志
- [ ] 测试健康检查接口
```powershell
# 在新的PowerShell窗口中执行
Invoke-RestMethod -Uri "http://localhost:8080/health"
```
预期结果: 返回状态码 200
- [ ] 测试Prometheus指标接口
```powershell
Invoke-RestMethod -Uri "http://localhost:8080/metrics"
```
预期结果: 返回指标数据
### 8. API功能测试
- [ ] 测试用户注册
```powershell
Invoke-RestMethod -Uri "http://localhost:8080/api/v1/auth/register" `
-Method POST `
-ContentType "application/json" `
-Body '{"username":"testuser","password":"Test123456","email":"test@example.com"}'
```
预期结果: 返回成功消息和用户信息
- [ ] 测试用户登录
```powershell
$response = Invoke-RestMethod -Uri "http://localhost:8080/api/v1/auth/login" `
-Method POST `
-ContentType "application/json" `
-Body '{"account":"admin","password":"<initialized-password>"}'
```
预期结果: 返回 access_token 和 refresh_token
- [ ] 测试获取用户信息
```powershell
$token = $response.access_token
Invoke-RestMethod -Uri "http://localhost:8080/api/v1/auth/userinfo" `
-Headers @{Authorization = "Bearer $token"}
```
预期结果: 返回用户信息
---
## 🐳 Docker配置检查
### 9. Docker环境验证
- [ ] 检查Docker是否安装
```powershell
docker --version
```
预期结果: 显示Docker版本
- [ ] 启动Docker服务如果需要
### 10. Docker Compose测试
- [ ] 构建并启动服务
```powershell
cd D:\project
docker-compose up -d
```
预期结果: 容器启动成功
- [ ] 查看容器状态
```powershell
docker-compose ps
```
预期结果: 容器状态为 "Up"
- [ ] 查看日志
```powershell
docker-compose logs
```
预期结果: 无错误日志
- [ ] 停止服务
```powershell
docker-compose down
```
预期结果: 容器停止并删除
---
## 📁 IDE配置更新
### 11. VS Code配置如果使用
- [ ] 更新工作区路径
- File → Open Folder → 选择 `D:\project`
- 保存新的工作区配置
- [ ] 更新launch.json调试配置
```json
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch Package",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}/cmd/server",
"cwd": "${workspaceFolder}"
}
]
}
```
- [ ] 更新settings.json工作区设置
```json
{
"go.toolsGopath": "${workspaceFolder}",
"go.gopath": "${workspaceFolder}",
"go.inferGopath": false
}
```
### 12. GoLand配置如果使用
- [ ] 打开新项目
- File → Open → 选择 `D:\project`
- 选择 "Open as Go Module"
- [ ] 配置GOROOT和GOPATH
- File → Settings → Go → GOROOT
- 确认GOROOT指向正确的Go安装目录
- [ ] 配置运行配置
- Run → Edit Configurations
- 更新Working directory为 `D:\project`
---
## 🔒 配置文件验证
### 13. 配置文件检查
- [ ] 检查配置文件路径(相对路径,无需修改)
```powershell
Get-Content D:\project\configs\config.yaml
```
**关键配置项**:
- `database.sqlite.path: ./data/user_management.db`
- `logging.output: [stdout, ./logs/app.log]`
这些使用相对路径会自动使用D:\project作为基准
- [ ] 确认配置正确
- 服务器端口: 8080
- 数据库类型: sqlite
- 日志级别: info
### 14. 测试配置加载
- [ ] 启动项目并检查配置
```powershell
go run cmd/server/main.go
```
预期结果: 控制台显示配置信息
---
## 📊 数据迁移检查(如果有)
### 15. 检查是否有现有数据
- [ ] 检查C盘是否有数据库文件
```powershell
Test-Path c:\Users\Admin\WorkBuddy\20260310215221\data\user_management.db
```
- [ ] 如果有,复制到新位置
```powershell
New-Item -ItemType Directory -Path D:\project\data -Force
Copy-Item c:\Users\Admin\WorkBuddy\20260310215221\data\*.db D:\project\data\
```
- [ ] 检查是否有日志文件
```powershell
Test-Path c:\Users\Admin\WorkBuddy\20260310215221\logs\*.log
```
- [ ] 如果有,决定是否迁移日志(通常不需要)
---
## ✅ 最终确认
### 16. 功能完整性测试
- [ ] 列出所有已实现的功能并进行测试
- [ ] 用户注册
- [ ] 用户登录
- [ ] JWT认证
- [ ] 用户信息获取
- [ ] 角色权限管理
- [ ] 设备管理
- [ ] OAuth社交登录
- [ ] 验证码系统
- [ ] 限流保护
- [ ] 健康检查
- [ ] Prometheus监控
### 17. 性能测试(可选)
- [ ] 压力测试
```powershell
# 使用Apache Bench或其他压力测试工具
ab -n 1000 -c 10 http://localhost:8080/health
```
- [ ] 检查响应时间和资源占用
---
## 🧹 清理C盘旧文件
### ⚠️ 重要:只有完成上述所有检查后,才能执行此步骤!
### 18. 备份C盘旧文件可选
- [ ] 如果担心,可以先压缩备份
```powershell
Compress-Archive -Path c:\Users\Admin\WorkBuddy\20260310215221 `
-DestinationPath C:\project_backup.zip
```
### 19. 删除C盘旧文件
- [ ] 确认D盘项目完全正常后
```powershell
Remove-Item -Path "c:\Users\Admin\WorkBuddy\20260310215221" -Recurse -Force
```
- [ ] 验证删除成功
```powershell
Test-Path c:\Users\Admin\WorkBuddy\20260310215221
```
预期结果: 返回 `False`
### 20. 验证C盘空间释放
- [ ] 检查C盘可用空间
```powershell
Get-PSDrive C | Select-Object Used, Free
```
---
## 📝 检查记录表
| 检查项 | 状态 | 备注 |
|--------|------|------|
| 1. 文件完整性检查 | ⬜ | |
| 2. 文件数量验证 | ⬜ | |
| 3. 文件大小验证 | ⬜ | |
| 4. Go环境安装 | ⬜ | |
| 5. Go模块验证 | ⬜ | |
| 6. 编译验证 | ⬜ | |
| 7. 启动项目 | ⬜ | |
| 8. API功能测试 | ⬜ | |
| 9. Docker环境验证 | ⬜ | |
| 10. Docker Compose测试 | ⬜ | |
| 11. VS Code配置 | ⬜ | |
| 12. GoLand配置 | ⬜ | |
| 13. 配置文件检查 | ⬜ | |
| 14. 测试配置加载 | ⬜ | |
| 15. 数据迁移检查 | ⬜ | |
| 16. 功能完整性测试 | ⬜ | |
| 17. 性能测试 | ⬜ | |
| 18. 备份C盘旧文件 | ⬜ | |
| 19. 删除C盘旧文件 | ⬜ | |
| 20. 验证C盘空间释放 | ⬜ | |
---
## 🎯 快速检查脚本
保存为 `quick_check.ps1` 并运行:
```powershell
# 快速检查脚本
Write-Host "====================================" -ForegroundColor Cyan
Write-Host "项目迁移快速检查" -ForegroundColor Cyan
Write-Host "====================================" -ForegroundColor Cyan
Write-Host ""
# 1. 检查关键文件
Write-Host "1. 检查关键文件..." -ForegroundColor Yellow
$files = @("go.mod", "README.md", "cmd\server\main.go", "configs\config.yaml")
foreach ($file in $files) {
$path = "D:\project\$file"
$status = if (Test-Path $path) { "✅" } else { "❌" }
Write-Host " $status $file"
}
Write-Host ""
# 2. 检查Go环境
Write-Host "2. 检查Go环境..." -ForegroundColor Yellow
try {
$goVersion = go version 2>&1
Write-Host " ✅ Go已安装: $goVersion"
} catch {
Write-Host " ❌ Go未安装"
}
Write-Host ""
# 3. 统计文件
Write-Host "3. 统计文件..." -ForegroundColor Yellow
$fileCount = (Get-ChildItem -Path D:\project -Recurse -File | Measure-Object).Count
Write-Host " 文件数: $fileCount"
Write-Host ""
# 4. 计算大小
Write-Host "4. 计算大小..." -ForegroundColor Yellow
$size = [math]::Round((Get-ChildItem -Path D:\project -Recurse | Measure-Object -Property Length -Sum).Sum / 1MB, 2)
Write-Host " 总大小: ${size} MB"
Write-Host ""
Write-Host "====================================" -ForegroundColor Cyan
Write-Host "检查完成!" -ForegroundColor Green
Write-Host "====================================" -ForegroundColor Cyan
```
运行方式:
```powershell
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
.\quick_check.ps1
```
---
## 📞 遇到问题?
如果检查过程中遇到问题:
1. **编译失败**
- 检查Go版本是否 >= 1.23
- 运行 `go mod tidy` 整理依赖
- 查看错误信息并修复
2. **运行失败**
- 检查端口8080是否被占用
- 检查配置文件是否正确
- 查看日志文件排查问题
3. **API测试失败**
- 确认服务器已启动
- 检查请求格式是否正确
- 查看服务器日志
4. **Docker问题**
- 确认Docker服务已启动
- 检查docker-compose.yml配置
- 查看Docker日志
---
**记住**: 只有完成所有检查项确认D盘项目完全正常后才能删除C盘旧文件