Files
orangecat/scripts/test/test_migration.js
Your NameandClaude Opus 4.5 295e39eddf fix: update scripts to use environment variables
Scripts now read from .env.local using dotenv instead of
having hardcoded values or placeholders.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-07 13:15:56 +01:00

54 lines
1.6 KiB
JavaScript

// Quick test of the fixed migration
import { createClient } from '@supabase/supabase-js';
import { config } from 'dotenv';
config({ path: '.env.local' });
const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL;
const supabaseKey = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY;
if (!supabaseUrl || !supabaseKey) {
console.error('Missing NEXT_PUBLIC_SUPABASE_URL or NEXT_PUBLIC_SUPABASE_ANON_KEY');
process.exit(1);
}
const supabase = createClient(supabaseUrl, supabaseKey);
async function testMigration() {
console.log('🧪 Testing migration fixes...');
try {
// Test if tables exist
const tables = ['user_products', 'user_services', 'loans', 'conversations', 'timeline_events', 'donations'];
for (const table of tables) {
try {
const { error } = await supabase.from(table).select('count').limit(1);
if (!error) {
console.log(`✅ ${table} exists`);
} else {
console.log(`❌ ${table} missing: ${error.message}`);
}
} catch (e) {
console.log(`❌ ${table} error: ${e.message}`);
}
}
// Test timeline_event_stats view
try {
const { error } = await supabase.from('timeline_event_stats').select('event_id').limit(1);
if (!error) {
console.log('✅ timeline_event_stats view works');
} else {
console.log(`❌ timeline_event_stats error: ${error.message}`);
}
} catch (e) {
console.log(`❌ timeline_event_stats error: ${e.message}`);
}
} catch (error) {
console.error('❌ Test failed:', error.message);
}
}
testMigration();