lot of bugfixes, better migration script

This commit is contained in:
Amruth Pillai
2026-01-23 01:07:52 +01:00
parent a10954ed14
commit 35e2daa807
95 changed files with 3661 additions and 3645 deletions
+16 -6
View File
@@ -1,18 +1,28 @@
import { sql } from "drizzle-orm";
import { drizzle } from "drizzle-orm/node-postgres";
import { Pool } from "pg";
import { env } from "@/utils/env";
const pool = new Pool({ connectionString: env.DATABASE_URL });
const db = drizzle({ client: pool });
const productionUrl = process.env.PRODUCTION_DATABASE_URL;
if (!productionUrl) throw new Error("PRODUCTION_DATABASE_URL is not set");
const productionPool = new Pool({ connectionString: productionUrl });
const productionDb = drizzle({ client: productionPool });
const localUrl = process.env.DATABASE_URL;
if (!localUrl) throw new Error("DATABASE_URL is not set");
const localPool = new Pool({ connectionString: localUrl });
const localDb = drizzle({ client: localPool });
try {
const result = await db.execute(sql`SELECT 1 as connected`);
console.log("✅ Database connection successful", JSON.stringify(result));
const productionResult = await productionDb.execute(sql`SELECT 1 as connected`);
console.log("✅ Production database connection successful", JSON.stringify(productionResult));
const localResult = await localDb.execute(sql`SELECT 1 as connected`);
console.log("✅ Local database connection successful", JSON.stringify(localResult));
} catch (error) {
console.error("🚨 Database connection failed:", error);
process.exit(1);
} finally {
await pool.end();
await productionPool.end();
await localPool.end();
process.exit(0);
}