-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinspect-database-tables.js
More file actions
65 lines (55 loc) · 1.84 KB
/
Copy pathinspect-database-tables.js
File metadata and controls
65 lines (55 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Inspect database table structure
const { createClient } = require('@supabase/supabase-js');
async function inspectDatabaseTables() {
console.log('Inspecting database table structure...');
const supabase = createClient(
process.env.NEXT_PUBLIC_SUPABASE_URL,
process.env.SUPABASE_SERVICE_ROLE_KEY,
{
auth: {
autoRefreshToken: false,
persistSession: false,
},
}
);
try {
// Try different possible table names for users
const possibleTables = ['users', 'profiles', 'user_profiles'];
for (const tableName of possibleTables) {
console.log(`\n--- Testing table: ${tableName} ---`);
try {
const { data, error } = await supabase
.from(tableName)
.select('*')
.limit(1);
if (error) {
console.log(`❌ Table ${tableName} error:`, error.message);
} else {
console.log(`✅ Table ${tableName} exists and is accessible`);
console.log(` Sample data:`, data);
}
} catch (e) {
console.log(`❌ Table ${tableName} exception:`, e.message);
}
}
// Try to get table schema information
console.log('\n--- Testing table information ---');
try {
// This might not work with regular Supabase client, but let's try
const { data: tables, error: tableError } = await supabase
.rpc('get_table_info'); // This RPC might not exist
if (tableError) {
console.log('Table info RPC not available:', tableError.message);
} else {
console.log('Available tables:', tables);
}
} catch (e) {
console.log('Table info not available via RPC');
}
} catch (error) {
console.error('General error:', error);
}
}
// Load environment variables
require('dotenv').config({ path: '.env.local' });
inspectDatabaseTables();