From 38021cbc51b84681b68efee0ba74e267a70f0fc3 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 10 Jun 2026 12:47:46 +0200 Subject: [PATCH] db: DATABASE_URL-Schema auf postgresql:// (wie feuerwehr_dashboard) Dashboard nutzt das Format postgresql://USER:PASS@HOST:PORT/DB. Angeglichen in docker-compose.yml, .env.example (+ Host-Hinweis lokal=localhost / Container=postgres), vitest.setup.ts und env.test.ts. Funktional identisch (pg/Drizzle akzeptieren beide), aber konsistent mit dem bestehenden Setup. Co-Authored-By: Claude Opus 4.8 (1M context) --- .env.example | 5 ++++- docker-compose.yml | 2 +- src/lib/__tests__/env.test.ts | 2 +- vitest.setup.ts | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.env.example b/.env.example index ef9f640..e1745bd 100644 --- a/.env.example +++ b/.env.example @@ -4,7 +4,10 @@ NODE_ENV=development # Datenbank (Postgres) -DATABASE_URL=postgres://floriannetz:floriannetz@localhost:5432/floriannetz +# Datenbank (Postgres). Format: postgresql://USER:PASSWORT@HOST:PORT/DB +# Lokal (Host -> Docker-Postgres via docker-compose.dev.yml): HOST=localhost. +# Im Container setzt docker-compose.yml HOST automatisch auf den Service "postgres". +DATABASE_URL=postgresql://floriannetz:floriannetz@localhost:5432/floriannetz # Auth.js / NextAuth # AUTH_SECRET muss >= 32 Zeichen sein (z. B. `openssl rand -base64 32`) diff --git a/docker-compose.yml b/docker-compose.yml index 1b4c36c..898e98f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -28,7 +28,7 @@ services: condition: service_healthy environment: NODE_ENV: production - DATABASE_URL: postgres://${POSTGRES_USER:-floriannetz}:${POSTGRES_PASSWORD:-floriannetz}@postgres:5432/${POSTGRES_DB:-floriannetz} + DATABASE_URL: postgresql://${POSTGRES_USER:-floriannetz}:${POSTGRES_PASSWORD:-floriannetz}@postgres:5432/${POSTGRES_DB:-floriannetz} # Forwarded-Header + sichere Cookies hinter Traefik. AUTH_TRUST_HOST: "true" AUTH_URL: https://${APP_HOST} diff --git a/src/lib/__tests__/env.test.ts b/src/lib/__tests__/env.test.ts index 85f819e..7625d78 100644 --- a/src/lib/__tests__/env.test.ts +++ b/src/lib/__tests__/env.test.ts @@ -8,7 +8,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; const VALID_ENV = { NODE_ENV: "test", - DATABASE_URL: "postgres://user:pass@localhost:5432/floriannetz", + DATABASE_URL: "postgresql://user:pass@localhost:5432/floriannetz", AUTH_SECRET: "x".repeat(32), AUTH_URL: "http://localhost:3000", AUTHENTIK_ISSUER: "http://localhost:9000/application/o/floriannetz/", diff --git a/vitest.setup.ts b/vitest.setup.ts index 17f5ee5..74ee4f2 100644 --- a/vitest.setup.ts +++ b/vitest.setup.ts @@ -3,7 +3,7 @@ // Es wird KEINE echte DB-Verbindung geƶffnet (Pool ist lazy bis zur Query). const TEST_ENV: Record = { NODE_ENV: "test", - DATABASE_URL: "postgres://test:test@localhost:5432/test", + DATABASE_URL: "postgresql://test:test@localhost:5432/test", AUTH_SECRET: "test-secret-mindestens-32-zeichen-lang-xxxx", AUTH_URL: "http://localhost:3000", AUTH_TRUST_HOST: "true",