mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-15 00:01:10 +02:00
Applied formatting to 1487+ files using pnpm format:write - TypeScript/JavaScript files - Svelte components - Astro pages - JSON configs - Markdown docs 13 files still need manual review (Astro JSX comments)
44 lines
1.1 KiB
TypeScript
44 lines
1.1 KiB
TypeScript
/**
|
|
* Test database connection
|
|
* Usage: pnpm db:test
|
|
*/
|
|
|
|
import { getDb, closeDb, sql } from './client.js';
|
|
|
|
async function testConnection() {
|
|
console.log('Testing database connection...\n');
|
|
|
|
try {
|
|
const db = getDb();
|
|
|
|
// Test basic connection
|
|
const result = await db.execute(sql`SELECT NOW() as current_time, version() as pg_version`);
|
|
console.log('✅ Connection successful!');
|
|
console.log(` Time: ${result[0].current_time}`);
|
|
console.log(` PostgreSQL: ${result[0].pg_version}\n`);
|
|
|
|
// List tables
|
|
const tables = await db.execute(sql`
|
|
SELECT tablename
|
|
FROM pg_tables
|
|
WHERE schemaname = 'public'
|
|
ORDER BY tablename
|
|
`);
|
|
|
|
if (tables.length > 0) {
|
|
console.log('📋 Tables in database:');
|
|
tables.forEach((t: any) => console.log(` - ${t.tablename}`));
|
|
} else {
|
|
console.log('📋 No tables found. Run "pnpm db:push" to create schema.');
|
|
}
|
|
|
|
console.log('\n✅ All tests passed!');
|
|
} catch (error) {
|
|
console.error('❌ Connection failed:', error);
|
|
process.exit(1);
|
|
} finally {
|
|
await closeDb();
|
|
}
|
|
}
|
|
|
|
testConnection();
|