Summary: - Fix pg-boss queue conflict (duplicate key violation on queue_pkey) - Add global error listener to prevent process crash - Reduce connection pool from 10 to 4 - Add graceful shutdown handling (SIGTERM/SIGINT) - Fix researchWorker recursive call bug in catch block - Make screeningWorker idempotent using upsert Security Standards (v1.1): - Prohibit recursive retry in Worker catch blocks - Prohibit payload bloat (only store fileKey/ID in job.data) - Require Worker idempotency (upsert + unique constraint) - Recommend task-specific expireInSeconds settings - Document graceful shutdown pattern New Features: - PKB signed URL endpoint for document preview/download - pg_bigm installation guide for Docker - Dockerfile.postgres-with-extensions for pgvector + pg_bigm Documentation: - Update Postgres-Only async task processing guide (v1.1) - Add troubleshooting SQL queries - Update safety checklist Tested: Local verification passed
94 lines
2.5 KiB
TypeScript
94 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());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|