Features:
- Backend: SystemKbService with full CRUD (knowledge bases + documents)
- Backend: 8 RESTful API endpoints (list/detail/create/update/delete/upload/download)
- Backend: OSS storage integration (system/knowledge-bases/{kbId}/{docId})
- Backend: RAG engine integration (document parsing, chunking, vectorization)
- Frontend: SystemKbListPage with card-based layout
- Frontend: SystemKbDetailPage with document management table
- Frontend: Master-Detail UX pattern for better user experience
- Document upload (single/batch), download (preserving original filename), delete
Technical:
- Database migration for system_knowledge_bases and system_kb_documents tables
- OSSAdapter.getSignedUrl with Content-Disposition for original filename
- Reuse RAG engine from common/rag for document processing
Tested: Local environment verified, all features working
37 lines
1.0 KiB
JavaScript
37 lines
1.0 KiB
JavaScript
const { PrismaClient } = require('@prisma/client');
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
const prisma = new PrismaClient();
|
|
|
|
async function main() {
|
|
const sqlPath = path.join(__dirname, 'prisma/migrations/20260128_add_system_knowledge_base/migration.sql');
|
|
const sql = fs.readFileSync(sqlPath, 'utf-8');
|
|
|
|
// 按语句分割执行
|
|
const statements = sql.split(';').filter(s => s.trim());
|
|
|
|
console.log(`Executing ${statements.length} SQL statements...`);
|
|
|
|
for (let i = 0; i < statements.length; i++) {
|
|
const stmt = statements[i].trim();
|
|
if (!stmt) continue;
|
|
|
|
try {
|
|
await prisma.$executeRawUnsafe(stmt);
|
|
console.log(`[${i + 1}/${statements.length}] OK`);
|
|
} catch (error) {
|
|
if (error.message.includes('already exists')) {
|
|
console.log(`[${i + 1}/${statements.length}] SKIPPED (already exists)`);
|
|
} else {
|
|
console.error(`[${i + 1}/${statements.length}] ERROR:`, error.message);
|
|
}
|
|
}
|
|
}
|
|
|
|
console.log('\nDone!');
|
|
await prisma.$disconnect();
|
|
}
|
|
|
|
main();
|