fix: use percent-encoded DATABASE_URL instead of split DB_PASSWORD trick
Drizzle ORM mutates client.options (parsers/serializers) after the postgres client is created, which causes the separately-passed password option to be lost on the actual connection attempt. Root cause confirmed on VPS: raw postgres.js query succeeded while drizzle.execute() failed with auth error. Fix: encode the password directly in DATABASE_URL (%23 = #, %5D = ], %3D = =). postgres.js decodes percent-encoding correctly. No separate DB_PASSWORD env var needed in the app container anymore. DB_PASSWORD is still used by the Postgres container (POSTGRES_PASSWORD). Coolify env var to set: DATABASE_URL=postgres://wc:<encoded-pass>@db:5432/worldcup Also adds resolver-level isMissingTable() guards so the app returns empty results instead of GraphQL errors on a fresh deploy before sync runs. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+10
-7
@@ -1,7 +1,13 @@
|
||||
# ── Production (Coolify) ────────────────────────────────────────────────────
|
||||
# DB_PASSWORD is passed separately so special characters never need URL-encoding.
|
||||
# DATABASE_URL is constructed inside docker-compose.yml and does NOT need to be
|
||||
# set in Coolify — only DB_PASSWORD is required.
|
||||
# DATABASE_URL must include the password. Special characters must be
|
||||
# percent-encoded so the URL parser handles them correctly:
|
||||
# # → %23 ] → %5D = → %3D @ → %40
|
||||
#
|
||||
# Example with password "p#ss]w=rd":
|
||||
# DATABASE_URL=postgres://wc:p%23ss%5Dw%3Drd@db:5432/worldcup
|
||||
#
|
||||
# DB_PASSWORD is used ONLY by the Postgres container (no encoding needed).
|
||||
DATABASE_URL=postgres://wc:changeme@db:5432/worldcup
|
||||
DB_PASSWORD=changeme
|
||||
|
||||
# Traefik (set TRAEFIK_ENABLED=true when deploying behind Traefik)
|
||||
@@ -9,8 +15,5 @@ TRAEFIK_ENABLED=false
|
||||
TRAEFIK_HOST=worldcup.example.com
|
||||
NETWORK_NAME=traefik-network
|
||||
|
||||
# ── Local development ────────────────────────────────────────────────────────
|
||||
# Set DATABASE_URL when running pnpm dev or pnpm sync on the host directly.
|
||||
# The password can be plain-text here since it goes through the postgres driver,
|
||||
# not URL parsing, when DB_PASSWORD is unset.
|
||||
# ── Local development ─────────────────────────────────────────────────────────
|
||||
# DATABASE_URL=postgres://wc:wc@localhost:5432/worldcup
|
||||
|
||||
Reference in New Issue
Block a user