-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-db.js
More file actions
35 lines (28 loc) · 1.09 KB
/
test-db.js
File metadata and controls
35 lines (28 loc) · 1.09 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
// Simple test script to check database connection and table
import { sql } from './lib/db.ts';
async function testDatabase() {
try {
console.log('Testing database connection...');
// Test basic connection
const healthCheck = await sql`SELECT 1 as test`;
console.log('Health check:', healthCheck);
// Test if cuny_campus_locations table exists
const tableExists = await sql`
SELECT EXISTS (
SELECT FROM information_schema.tables
WHERE table_schema = 'public'
AND table_name = 'cuny_campus_locations'
) as exists
`;
console.log('Table exists:', tableExists);
// Test querying the table
const campuses = await sql`SELECT DISTINCT campus FROM cuny_campus_locations LIMIT 5`;
console.log('Sample campuses:', campuses);
// Test the exact query that's failing
const testQuery = await sql.unsafe('SELECT DISTINCT campus FROM cuny_campus_locations LIMIT 5');
console.log('Unsafe query result:', testQuery);
} catch (error) {
console.error('Database test failed:', error);
}
}
testDatabase();