- 创建统一的下载错误处理模块 (lib/download-errors.ts) - 实现13种错误类型分类和中文错误消息 - 后端统一使用 createDownloadError 创建标准化错误响应 - 前端统一使用 parseDownloadError 解析错误并显示 - 修复正式系统数据库Schema,添加产品全案相关字段和表 - 执行数据库迁移:添加 task_no, task_status, task_fetched_at 字段 - 创建 material_assets, api_keys, api_call_logs 表
170 lines
6.3 KiB
PowerShell
170 lines
6.3 KiB
PowerShell
# 影子系统阶段三和阶段四测试脚本
|
||
# 执行完整的迁移和测试流程
|
||
|
||
$ErrorActionPreference = "Stop"
|
||
|
||
Write-Host "========================================" -ForegroundColor Cyan
|
||
Write-Host "影子系统阶段三和阶段四测试脚本" -ForegroundColor Cyan
|
||
Write-Host "========================================" -ForegroundColor Cyan
|
||
Write-Host ""
|
||
|
||
# 设置环境变量(影子系统)
|
||
$env:DATABASE_URL = "postgresql://gongxiangpan:gongxiangpan123@192.168.58.20:5432/lobechat_stage"
|
||
|
||
Write-Host "✅ 环境变量已设置" -ForegroundColor Green
|
||
Write-Host " 数据库: lobechat_stage (影子系统)" -ForegroundColor Cyan
|
||
Write-Host ""
|
||
|
||
# 切换到项目根目录
|
||
Set-Location $PSScriptRoot\..
|
||
$projectRoot = Get-Location
|
||
Write-Host "项目目录: $projectRoot" -ForegroundColor Cyan
|
||
Write-Host ""
|
||
|
||
# 步骤1: 添加Department表的updatedAt字段(如果不存在)
|
||
Write-Host "📋 步骤1: 添加Department表的updatedAt字段..." -ForegroundColor Yellow
|
||
Write-Host " 执行: npx tsx scripts/add-department-updatedAt.ts" -ForegroundColor Gray
|
||
try {
|
||
npx tsx scripts/add-department-updatedAt.ts
|
||
if ($LASTEXITCODE -ne 0) {
|
||
Write-Host " ⚠️ 添加字段失败,但可能不影响后续步骤" -ForegroundColor Yellow
|
||
} else {
|
||
Write-Host " ✅ updatedAt字段已准备" -ForegroundColor Green
|
||
}
|
||
} catch {
|
||
Write-Host " ⚠️ 添加字段过程出错: $_" -ForegroundColor Yellow
|
||
}
|
||
Write-Host ""
|
||
|
||
# 步骤2: 应用Schema变更(阶段三和阶段四)
|
||
Write-Host "📋 步骤2: 应用Schema变更(阶段三和阶段四)..." -ForegroundColor Yellow
|
||
Write-Host " 执行: npx prisma db push" -ForegroundColor Gray
|
||
try {
|
||
npx prisma db push --accept-data-loss
|
||
if ($LASTEXITCODE -ne 0) {
|
||
throw "Schema更新失败"
|
||
}
|
||
Write-Host " ✅ Schema更新成功" -ForegroundColor Green
|
||
} catch {
|
||
Write-Host " ❌ Schema更新失败: $_" -ForegroundColor Red
|
||
exit 1
|
||
}
|
||
Write-Host ""
|
||
|
||
# 步骤3: 生成Prisma Client
|
||
Write-Host "📋 步骤3: 生成Prisma Client..." -ForegroundColor Yellow
|
||
try {
|
||
npx prisma generate
|
||
if ($LASTEXITCODE -ne 0) {
|
||
throw "Prisma Client生成失败"
|
||
}
|
||
Write-Host " ✅ Prisma Client生成成功" -ForegroundColor Green
|
||
} catch {
|
||
Write-Host " ❌ Prisma Client生成失败: $_" -ForegroundColor Red
|
||
exit 1
|
||
}
|
||
Write-Host ""
|
||
|
||
# 步骤4: 阶段三迁移 - 部门层级结构
|
||
Write-Host "📋 步骤4: 阶段三迁移 - 部门层级结构..." -ForegroundColor Yellow
|
||
Write-Host " 执行: npx tsx scripts/migrate-department-hierarchy-safe.ts" -ForegroundColor Gray
|
||
try {
|
||
npx tsx scripts/migrate-department-hierarchy-safe.ts
|
||
if ($LASTEXITCODE -ne 0) {
|
||
throw "阶段三迁移失败"
|
||
}
|
||
Write-Host " ✅ 阶段三迁移成功" -ForegroundColor Green
|
||
} catch {
|
||
Write-Host " ❌ 阶段三迁移失败: $_" -ForegroundColor Red
|
||
exit 1
|
||
}
|
||
Write-Host ""
|
||
|
||
# 步骤5: 验证阶段三
|
||
Write-Host "📋 步骤5: 验证阶段三迁移结果..." -ForegroundColor Yellow
|
||
Write-Host " 执行: npx tsx scripts/verify-migration.ts 3" -ForegroundColor Gray
|
||
try {
|
||
npx tsx scripts/verify-migration.ts 3
|
||
if ($LASTEXITCODE -ne 0) {
|
||
Write-Host " ⚠️ 验证发现问题,请检查输出" -ForegroundColor Yellow
|
||
} else {
|
||
Write-Host " ✅ 阶段三验证通过" -ForegroundColor Green
|
||
}
|
||
} catch {
|
||
Write-Host " ⚠️ 验证过程出错: $_" -ForegroundColor Yellow
|
||
}
|
||
Write-Host ""
|
||
|
||
# 步骤6: 阶段四迁移 - 角色枚举扩展
|
||
Write-Host "📋 步骤6: 阶段四迁移 - 角色枚举扩展..." -ForegroundColor Yellow
|
||
Write-Host " 执行: npx tsx scripts/migrate-role-enum-safe.ts" -ForegroundColor Gray
|
||
try {
|
||
npx tsx scripts/migrate-role-enum-safe.ts
|
||
if ($LASTEXITCODE -ne 0) {
|
||
throw "阶段四迁移失败"
|
||
}
|
||
Write-Host " ✅ 阶段四迁移成功" -ForegroundColor Green
|
||
} catch {
|
||
Write-Host " ❌ 阶段四迁移失败: $_" -ForegroundColor Red
|
||
exit 1
|
||
}
|
||
Write-Host ""
|
||
|
||
# 步骤7: 验证阶段四
|
||
Write-Host "📋 步骤7: 验证阶段四迁移结果..." -ForegroundColor Yellow
|
||
Write-Host " 执行: npx tsx scripts/verify-migration.ts 4" -ForegroundColor Gray
|
||
try {
|
||
npx tsx scripts/verify-migration.ts 4
|
||
if ($LASTEXITCODE -ne 0) {
|
||
Write-Host " ⚠️ 验证发现问题,请检查输出" -ForegroundColor Yellow
|
||
} else {
|
||
Write-Host " ✅ 阶段四验证通过" -ForegroundColor Green
|
||
}
|
||
} catch {
|
||
Write-Host " ⚠️ 验证过程出错: $_" -ForegroundColor Yellow
|
||
}
|
||
Write-Host ""
|
||
|
||
# 步骤8: 完整验证
|
||
Write-Host "📋 步骤8: 完整验证(所有阶段)..." -ForegroundColor Yellow
|
||
Write-Host " 执行: npx tsx scripts/verify-migration.ts" -ForegroundColor Gray
|
||
try {
|
||
npx tsx scripts/verify-migration.ts
|
||
if ($LASTEXITCODE -ne 0) {
|
||
Write-Host " ⚠️ 验证发现问题,请检查输出" -ForegroundColor Yellow
|
||
} else {
|
||
Write-Host " ✅ 完整验证通过" -ForegroundColor Green
|
||
}
|
||
} catch {
|
||
Write-Host " ⚠️ 验证过程出错: $_" -ForegroundColor Yellow
|
||
}
|
||
Write-Host ""
|
||
|
||
# 步骤9: 功能测试(阶段三和阶段四)
|
||
Write-Host "📋 步骤9: 功能测试(阶段三和阶段四)..." -ForegroundColor Yellow
|
||
Write-Host " 执行: npx tsx scripts/test-shadow-stages-3-4.ts" -ForegroundColor Gray
|
||
try {
|
||
npx tsx scripts/test-shadow-stages-3-4.ts
|
||
if ($LASTEXITCODE -ne 0) {
|
||
Write-Host " ⚠️ 功能测试发现问题,请检查输出" -ForegroundColor Yellow
|
||
} else {
|
||
Write-Host " ✅ 功能测试通过" -ForegroundColor Green
|
||
}
|
||
} catch {
|
||
Write-Host " ⚠️ 功能测试过程出错: $_" -ForegroundColor Yellow
|
||
}
|
||
Write-Host ""
|
||
|
||
Write-Host "========================================" -ForegroundColor Green
|
||
Write-Host "✅ 测试执行完成" -ForegroundColor Green
|
||
Write-Host "========================================" -ForegroundColor Green
|
||
Write-Host ""
|
||
Write-Host "📋 下一步:" -ForegroundColor Yellow
|
||
Write-Host " 1. 检查上述测试输出,确认没有严重错误" -ForegroundColor White
|
||
Write-Host " 2. 在浏览器中访问影子系统进行手动测试" -ForegroundColor White
|
||
Write-Host " 3. 访问: http://192.168.58.20:5320" -ForegroundColor Cyan
|
||
Write-Host " 4. 测试部门层级管理功能" -ForegroundColor White
|
||
Write-Host " 5. 测试新角色权限功能" -ForegroundColor White
|
||
Write-Host ""
|
||
|