🌐 Cloud-Native Architecture: - Firebase Functions deployment (no Docker) - Supabase database (replacing local PostgreSQL) - Google Cloud Storage integration - Document AI + Agentic RAG processing pipeline - Claude-3.5-Sonnet LLM integration ✅ Full BPCP CIM Review Template (7 sections): - Deal Overview - Business Description - Market & Industry Analysis - Financial Summary (with historical financials table) - Management Team Overview - Preliminary Investment Thesis - Key Questions & Next Steps 🔧 Cloud Migration Improvements: - PostgreSQL → Supabase migration complete - Local storage → Google Cloud Storage - Docker deployment → Firebase Functions - Schema mapping fixes (camelCase/snake_case) - Enhanced error handling and logging - Vector database with fallback mechanisms 📄 Complete End-to-End Cloud Workflow: 1. Upload PDF → Document AI extraction 2. Agentic RAG processing → Structured CIM data 3. Store in Supabase → Vector embeddings 4. Auto-generate PDF → Full BPCP template 5. Download complete CIM review 🚀 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
87 lines
2.8 KiB
JavaScript
87 lines
2.8 KiB
JavaScript
const { createClient } = require('@supabase/supabase-js');
|
|
require('dotenv').config();
|
|
|
|
const supabase = createClient(process.env.SUPABASE_URL, process.env.SUPABASE_SERVICE_KEY);
|
|
|
|
async function checkTableSchema() {
|
|
console.log('🔧 Checking document_chunks table...');
|
|
|
|
// Try to select from the table to see what columns exist
|
|
const { data, error } = await supabase
|
|
.from('document_chunks')
|
|
.select('*')
|
|
.limit(1);
|
|
|
|
if (error) {
|
|
console.log('❌ Error accessing table:', error.message);
|
|
if (error.message.includes('does not exist')) {
|
|
console.log('');
|
|
console.log('🛠️ Table does not exist. Need to create it with:');
|
|
console.log(`
|
|
CREATE TABLE document_chunks (
|
|
id UUID DEFAULT gen_random_uuid() PRIMARY KEY,
|
|
document_id TEXT NOT NULL,
|
|
content TEXT NOT NULL,
|
|
embedding VECTOR(1536),
|
|
metadata JSONB DEFAULT '{}',
|
|
chunk_index INTEGER NOT NULL,
|
|
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
|
|
updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
|
|
);
|
|
|
|
CREATE INDEX idx_document_chunks_document_id ON document_chunks(document_id);
|
|
CREATE INDEX idx_document_chunks_embedding ON document_chunks USING ivfflat (embedding vector_cosine_ops);
|
|
`);
|
|
}
|
|
return;
|
|
}
|
|
|
|
if (data && data.length > 0) {
|
|
console.log('✅ Table exists');
|
|
console.log('📋 Available columns:', Object.keys(data[0]));
|
|
|
|
const hasChunkIndex = 'chunk_index' in data[0];
|
|
const hasChunkIndexCamel = 'chunkIndex' in data[0];
|
|
|
|
console.log('Has chunk_index:', hasChunkIndex);
|
|
console.log('Has chunkIndex:', hasChunkIndexCamel);
|
|
|
|
if (!hasChunkIndex && !hasChunkIndexCamel) {
|
|
console.log('⚠️ Missing chunk index column.');
|
|
console.log('🛠️ Run this SQL to fix:');
|
|
console.log('ALTER TABLE document_chunks ADD COLUMN chunk_index INTEGER;');
|
|
}
|
|
} else {
|
|
console.log('📋 Table exists but is empty');
|
|
console.log('🧪 Testing insert to see schema...');
|
|
|
|
// Try to insert a test record to see what columns are expected
|
|
const { error: insertError } = await supabase
|
|
.from('document_chunks')
|
|
.insert({
|
|
document_id: 'test',
|
|
content: 'test content',
|
|
chunk_index: 1,
|
|
metadata: {}
|
|
})
|
|
.select();
|
|
|
|
if (insertError) {
|
|
console.log('❌ Insert failed:', insertError.message);
|
|
if (insertError.message.includes('chunkIndex')) {
|
|
console.log('⚠️ Table expects camelCase chunkIndex but code uses snake_case chunk_index');
|
|
} else if (insertError.message.includes('chunk_index')) {
|
|
console.log('⚠️ Missing chunk_index column');
|
|
}
|
|
} else {
|
|
console.log('✅ Test insert successful');
|
|
// Clean up test record
|
|
await supabase
|
|
.from('document_chunks')
|
|
.delete()
|
|
.eq('document_id', 'test');
|
|
}
|
|
}
|
|
}
|
|
|
|
checkTableSchema(); |