-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-db-connection.js
More file actions
36 lines (31 loc) · 1.09 KB
/
test-db-connection.js
File metadata and controls
36 lines (31 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
36
// Simple script to test database connection
const { PrismaClient } = require('./src/generated/prisma');
async function testConnection() {
const prisma = new PrismaClient();
try {
console.log('Testing database connection...');
// Try to query the database
const result = await prisma.$queryRaw`SELECT 1 as test`;
console.log('Connection successful!', result);
// Try to count certificates
const certificateCount = await prisma.certificate.count();
console.log(`Found ${certificateCount} certificates in the database`);
return true;
} catch (error) {
console.error('Database connection error:', error);
return false;
} finally {
await prisma.$disconnect();
}
}
testConnection()
.then(success => {
if (success) {
console.log('\nDatabase connection test passed!');
} else {
console.log('\nDatabase connection test failed!');
console.log('Please check your DATABASE_URL in .env.local');
console.log('Suggested format: postgresql://postgres:password@localhost:5432/decerts');
}
process.exit(success ? 0 : 1);
});