From 6adf09faa028e68f1fa8a74404700c99975a7004 Mon Sep 17 00:00:00 2001 From: florianfederspiel Date: Sat, 17 Jan 2026 15:15:26 +0100 Subject: [PATCH] DB Change con string --- backend/db/index.ts | 29 +++++++++++++++++++++-------- backend/src/index.ts | 1 + 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/backend/db/index.ts b/backend/db/index.ts index 974f8d9..7b41e19 100644 --- a/backend/db/index.ts +++ b/backend/db/index.ts @@ -1,13 +1,26 @@ -import { drizzle } from "drizzle-orm/node-postgres" -import { Pool } from "pg" -import {secrets} from "../src/utils/secrets"; -import * as schema from "./schema" +// src/db/index.ts +import { drizzle } from "drizzle-orm/node-postgres"; +import { Pool } from "pg"; +import * as schema from "./schema"; +console.log("[DB INIT] 1. Suche Connection String..."); +// Checken woher die URL kommt +let connectionString = process.env.DATABASE_URL; +if (connectionString) { + console.log("[DB INIT] -> Gefunden in process.env.DATABASE_URL"); +} else { + console.error("[DB INIT] ❌ KEIN CONNECTION STRING GEFUNDEN! .env nicht geladen?"); +} export const pool = new Pool({ - connectionString: secrets.DATABASE_URL, - max: 10, // je nach Last -}) + connectionString, + max: 10, +}); -export const db = drizzle(pool , {schema}) \ No newline at end of file +// TEST: Ist die DB wirklich da? +pool.query('SELECT NOW()') + .then(res => console.log(`[DB INIT] ✅ VERBINDUNG ERFOLGREICH! Zeit auf DB: ${res.rows[0].now}`)) + .catch(err => console.error(`[DB INIT] ❌ VERBINDUNGSFEHLER:`, err.message)); + +export const db = drizzle(pool, { schema }); \ No newline at end of file diff --git a/backend/src/index.ts b/backend/src/index.ts index 222f969..069ca8e 100644 --- a/backend/src/index.ts +++ b/backend/src/index.ts @@ -52,6 +52,7 @@ import {loadSecrets, secrets} from "./utils/secrets"; import {initMailer} from "./utils/mailer" import {initS3} from "./utils/s3"; + //Services import servicesPlugin from "./plugins/services";