Sprint 1-3 Completed (Backend + Frontend): Backend (Sprint 1-2): - Implement 5-layer Agent framework (Query->Planner->Executor->Tools->Reflection) - Create agent_schema with 6 tables (agent_definitions, stages, prompts, sessions, traces, reflexion_rules) - Create protocol_schema with 2 tables (protocol_contexts, protocol_generations) - Implement Protocol Agent core services (Orchestrator, ContextService, PromptBuilder) - Integrate LLM service adapter (DeepSeek/Qwen/GPT-5/Claude) - 6 API endpoints with full authentication - 10/10 API tests passed Frontend (Sprint 3): - Add Protocol Agent entry in AgentHub (indigo theme card) - Implement ProtocolAgentPage with 3-column layout - Collapsible sidebar (Gemini style, 48px <-> 280px) - StatePanel with 5 stage cards (scientific_question, pico, study_design, sample_size, endpoints) - ChatArea with sync button and action cards integration - 100% prototype design restoration (608 lines CSS) - Detailed endpoints structure: baseline, exposure, outcomes, confounders Features: - 5-stage dialogue flow for research protocol design - Conversation-driven interaction with sync-to-protocol button - Real-time context state management - One-click protocol generation button (UI ready, backend pending) Database: - agent_schema: 6 tables for reusable Agent framework - protocol_schema: 2 tables for Protocol Agent - Seed data: 1 agent + 5 stages + 9 prompts + 4 reflexion rules Code Stats: - Backend: 13 files, 4338 lines - Frontend: 14 files, 2071 lines - Total: 27 files, 6409 lines Status: MVP core functionality completed, pending frontend-backend integration testing Next: Sprint 4 - One-click protocol generation + Word export
130 lines
3.7 KiB
TypeScript
130 lines
3.7 KiB
TypeScript
import { PrismaClient } from '@prisma/client';
|
||
|
||
const prisma = new PrismaClient();
|
||
|
||
async function main() {
|
||
console.log('🔍 检查数据库中 Prisma 未管理的对象\n');
|
||
console.log('=' .repeat(70));
|
||
|
||
// 1. 获取所有数据库函数
|
||
console.log('\n📋 数据库函数 (Functions):');
|
||
const functions: any[] = await prisma.$queryRaw`
|
||
SELECT routine_schema, routine_name, routine_type
|
||
FROM information_schema.routines
|
||
WHERE routine_schema NOT IN ('pg_catalog', 'information_schema')
|
||
ORDER BY routine_schema, routine_name
|
||
`;
|
||
|
||
if (functions.length === 0) {
|
||
console.log(' 无自定义函数');
|
||
} else {
|
||
functions.forEach(f => console.log(` - ${f.routine_schema}.${f.routine_name} (${f.routine_type})`));
|
||
}
|
||
|
||
// 2. 获取所有索引(非主键、非外键)
|
||
console.log('\n📋 自定义索引 (Indexes):');
|
||
const indexes: any[] = await prisma.$queryRaw`
|
||
SELECT schemaname, tablename, indexname
|
||
FROM pg_indexes
|
||
WHERE schemaname NOT IN ('pg_catalog', 'information_schema')
|
||
AND indexname NOT LIKE '%pkey%'
|
||
AND indexname NOT LIKE '%_fkey%'
|
||
ORDER BY schemaname, tablename, indexname
|
||
LIMIT 30
|
||
`;
|
||
|
||
console.log(` 共 ${indexes.length} 个索引 (显示前30个)`);
|
||
|
||
// 3. 获取所有序列
|
||
console.log('\n📋 序列 (Sequences):');
|
||
const sequences: any[] = await prisma.$queryRaw`
|
||
SELECT sequence_schema, sequence_name
|
||
FROM information_schema.sequences
|
||
WHERE sequence_schema NOT IN ('pg_catalog', 'information_schema')
|
||
ORDER BY sequence_schema, sequence_name
|
||
`;
|
||
|
||
sequences.forEach(s => console.log(` - ${s.sequence_schema}.${s.sequence_name}`));
|
||
|
||
// 4. 检查枚举类型
|
||
console.log('\n📋 枚举类型 (Enums):');
|
||
const enums: any[] = await prisma.$queryRaw`
|
||
SELECT n.nspname as schema, t.typname as enum_name,
|
||
string_agg(e.enumlabel, ', ' ORDER BY e.enumsortorder) as values
|
||
FROM pg_type t
|
||
JOIN pg_enum e ON t.oid = e.enumtypid
|
||
JOIN pg_namespace n ON t.typnamespace = n.oid
|
||
WHERE n.nspname NOT IN ('pg_catalog', 'information_schema')
|
||
GROUP BY n.nspname, t.typname
|
||
ORDER BY n.nspname, t.typname
|
||
`;
|
||
|
||
enums.forEach(e => console.log(` - ${e.schema}.${e.enum_name}: [${e.values}]`));
|
||
|
||
// 5. 检查触发器
|
||
console.log('\n📋 触发器 (Triggers):');
|
||
const triggers: any[] = await prisma.$queryRaw`
|
||
SELECT trigger_schema, trigger_name, event_object_table
|
||
FROM information_schema.triggers
|
||
WHERE trigger_schema NOT IN ('pg_catalog', 'information_schema')
|
||
ORDER BY trigger_schema, trigger_name
|
||
`;
|
||
|
||
if (triggers.length === 0) {
|
||
console.log(' 无自定义触发器');
|
||
} else {
|
||
triggers.forEach(t => console.log(` - ${t.trigger_schema}.${t.trigger_name} on ${t.event_object_table}`));
|
||
}
|
||
|
||
// 6. 检查视图
|
||
console.log('\n📋 视图 (Views):');
|
||
const views: any[] = await prisma.$queryRaw`
|
||
SELECT table_schema, table_name
|
||
FROM information_schema.views
|
||
WHERE table_schema NOT IN ('pg_catalog', 'information_schema')
|
||
ORDER BY table_schema, table_name
|
||
`;
|
||
|
||
if (views.length === 0) {
|
||
console.log(' 无自定义视图');
|
||
} else {
|
||
views.forEach(v => console.log(` - ${v.table_schema}.${v.table_name}`));
|
||
}
|
||
|
||
// 7. 列出 Prisma 不管理的重要对象
|
||
console.log('\n\n⚠️ 需要手动管理的数据库对象 (Prisma 不管理):');
|
||
console.log(' 1. platform_schema.create_queue() 函数');
|
||
console.log(' 2. platform_schema.delete_queue() 函数');
|
||
console.log(' 3. platform_schema.job_state 枚举 (pg-boss 创建)');
|
||
console.log(' 4. platform_schema.job_common 表 (pg-boss 运行时创建)');
|
||
console.log(' 5. 各种索引和约束');
|
||
|
||
console.log('\n' + '=' .repeat(70));
|
||
}
|
||
|
||
main()
|
||
.catch(console.error)
|
||
.finally(() => prisma.$disconnect());
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|