Files
dc-recorder/test-pg-connection.ts
MythEclipse 35269b5bef feat: configure postgresql as primary database with neon connection
- Updated .env to use PostgreSQL (neondb) instead of SQLite
- Updated drizzle.ts to support DATABASE_URL connection string
- Regenerated migrations for PostgreSQL syntax
- Bot successfully connects and operates with PostgreSQL
- All database operations working correctly
2026-05-14 16:25:39 +07:00

27 lines
717 B
TypeScript

import "dotenv/config";
import { Pool } from "pg";
const connectionString = process.env.DATABASE_URL;
console.log("Testing connection to:", connectionString?.replace(/:[^:]*@/, ":***@"));
async function testConnection() {
const pool = new Pool({
connectionString,
connectionTimeoutMillis: 10000,
statement_timeout: 10000,
});
try {
const result = await pool.query("SELECT NOW()");
console.log("✅ Connection successful!");
console.log("✅ Query result:", result.rows[0]);
await pool.end();
process.exit(0);
} catch (error) {
console.error("❌ Connection failed:", error instanceof Error ? error.message : String(error));
process.exit(1);
}
}
testConnection();