mirror of
https://github.com/SrIzan10/helium.git
synced 2026-06-06 00:56:58 +00:00
chore: move to normal postgres
This commit is contained in:
@@ -1,4 +1,10 @@
|
||||
import { drizzle } from "drizzle-orm/neon-http";
|
||||
import { drizzle } from "drizzle-orm/node-postgres";
|
||||
import { Pool } from "pg";
|
||||
import * as schema from "./schema";
|
||||
|
||||
export const db = drizzle(process.env.DATABASE_URL!, { schema });
|
||||
// Create a connection pool
|
||||
const pool = new Pool({
|
||||
connectionString: process.env.DATABASE_URL!,
|
||||
});
|
||||
|
||||
export const db = drizzle(pool, { schema });
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { migrate } from "drizzle-orm/neon-http/migrator";
|
||||
import { drizzle } from "drizzle-orm/neon-http";
|
||||
import { migrate } from "drizzle-orm/node-postgres/migrator";
|
||||
import { drizzle } from "drizzle-orm/node-postgres";
|
||||
import { Pool } from "pg";
|
||||
import * as schema from "./schema";
|
||||
import { join } from "path";
|
||||
import { existsSync } from "fs";
|
||||
@@ -9,8 +10,13 @@ export async function runMigrations() {
|
||||
throw new Error("DATABASE_URL environment variable is not set");
|
||||
}
|
||||
|
||||
// Create a temporary pool for migrations
|
||||
const pool = new Pool({
|
||||
connectionString: process.env.DATABASE_URL,
|
||||
});
|
||||
|
||||
try {
|
||||
const db = drizzle(process.env.DATABASE_URL, { schema });
|
||||
const db = drizzle(pool, { schema });
|
||||
|
||||
// Determine the correct migrations folder path
|
||||
// In development: ./drizzle from project root
|
||||
@@ -29,5 +35,8 @@ export async function runMigrations() {
|
||||
} catch (error) {
|
||||
console.error("[DB] Migration failed:", error);
|
||||
throw error;
|
||||
} finally {
|
||||
// Close the pool after migrations
|
||||
await pool.end();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user