Features: - Migrate 10 agent prompts from hardcoded to database - Add grayscale preview support (DRAFT/ACTIVE distribution) - Implement 3-tier fallback (DB -> Cache -> Hardcoded) - Add version management and rollback capability Files changed: - backend/scripts/migrate-aia-prompts.ts (new migration script) - backend/src/common/prompt/prompt.fallbacks.ts (add AIA fallbacks) - backend/src/modules/aia/services/agentService.ts (integrate PromptService) - backend/src/modules/aia/services/conversationService.ts (pass userId) - backend/src/modules/aia/types/index.ts (fix AgentStage type) Documentation: - docs/03-业务模块/AIA-AI智能问答/06-开发记录/2026-01-18-Prompt管理系统集成.md - docs/02-通用能力层/00-通用能力层清单.md (add FileCard, Prompt management) - docs/00-系统总体设计/00-系统当前状态与开发指南.md (update to v3.6) Prompt codes: - AIA_SCIENTIFIC_QUESTION, AIA_PICO_ANALYSIS, AIA_TOPIC_EVALUATION - AIA_OUTCOME_DESIGN, AIA_CRF_DESIGN, AIA_SAMPLE_SIZE - AIA_PROTOCOL_WRITING, AIA_METHODOLOGY_REVIEW - AIA_PAPER_POLISH, AIA_PAPER_TRANSLATE Tested: Migration script executed, all 10 prompts inserted successfully
86 lines
2.5 KiB
TypeScript
86 lines
2.5 KiB
TypeScript
import { PrismaClient } from '@prisma/client';
|
|
|
|
const prisma = new PrismaClient();
|
|
|
|
async function main() {
|
|
console.log('🔍 检查 RVW 模块问题\n');
|
|
|
|
// 1. 检查用户 user-mock-001 是否存在
|
|
console.log('1. 检查用户 "user-mock-001":');
|
|
const users: any[] = await prisma.$queryRaw`
|
|
SELECT id, name, email, phone, role
|
|
FROM platform_schema.users
|
|
WHERE id = 'user-mock-001' OR email LIKE '%mock%' OR name LIKE '%mock%'
|
|
`;
|
|
|
|
if (users.length === 0) {
|
|
console.log(' ❌ 用户 "user-mock-001" 不存在!');
|
|
} else {
|
|
console.log(' ✅ 找到用户:');
|
|
users.forEach(u => console.log(` ${u.id}: ${u.name} (${u.email || u.phone})`));
|
|
}
|
|
|
|
// 2. 检查所有用户
|
|
console.log('\n2. 当前所有用户:');
|
|
const allUsers: any[] = await prisma.$queryRaw`
|
|
SELECT id, name, phone, role FROM platform_schema.users
|
|
`;
|
|
allUsers.forEach(u => console.log(` - ${u.id}: ${u.name} (${u.phone}) [${u.role}]`));
|
|
|
|
// 3. 检查 rvw_schema.review_tasks 表结构
|
|
console.log('\n3. rvw_schema.review_tasks 表结构:');
|
|
const cols: any[] = await prisma.$queryRaw`
|
|
SELECT column_name, data_type, is_nullable, column_default
|
|
FROM information_schema.columns
|
|
WHERE table_schema = 'rvw_schema' AND table_name = 'review_tasks'
|
|
ORDER BY ordinal_position
|
|
`;
|
|
cols.forEach(c => {
|
|
const nullable = c.is_nullable === 'YES' ? 'NULLABLE' : 'NOT NULL';
|
|
console.log(` ${c.column_name}: ${c.data_type} ${nullable}`);
|
|
});
|
|
|
|
// 4. 检查外键约束
|
|
console.log('\n4. review_tasks 的外键约束:');
|
|
const fks: any[] = await prisma.$queryRaw`
|
|
SELECT
|
|
tc.constraint_name,
|
|
kcu.column_name,
|
|
ccu.table_schema AS foreign_table_schema,
|
|
ccu.table_name AS foreign_table_name,
|
|
ccu.column_name AS foreign_column_name
|
|
FROM information_schema.table_constraints AS tc
|
|
JOIN information_schema.key_column_usage AS kcu
|
|
ON tc.constraint_name = kcu.constraint_name
|
|
JOIN information_schema.constraint_column_usage AS ccu
|
|
ON ccu.constraint_name = tc.constraint_name
|
|
WHERE tc.constraint_type = 'FOREIGN KEY'
|
|
AND tc.table_schema = 'rvw_schema'
|
|
AND tc.table_name = 'review_tasks'
|
|
`;
|
|
|
|
if (fks.length === 0) {
|
|
console.log(' 无外键约束');
|
|
} else {
|
|
fks.forEach(fk => {
|
|
console.log(` ${fk.column_name} -> ${fk.foreign_table_schema}.${fk.foreign_table_name}.${fk.foreign_column_name}`);
|
|
});
|
|
}
|
|
}
|
|
|
|
main()
|
|
.catch(console.error)
|
|
.finally(() => prisma.$disconnect());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|