From 69a32e9d374bdefff820e6826158687b39540eb1 Mon Sep 17 00:00:00 2001 From: spooner85 <50322218+spooner85@users.noreply.github.com> Date: Tue, 2 Dec 2025 16:10:44 +0100 Subject: [PATCH] Update init-data.sh The current version of the script creates the PostgreSQL user in lowercase only. This happens because the variable POSTGRES_NON_ROOT_USER is not quoted properly in the SQL command. As a result, any uppercase letters in the username are ignored, and the user is created in lowercase. This leads to connection issues when n8n tries to connect to PostgreSQL using the original username with mixed case, since PostgreSQL treats unquoted identifiers as lowercase by default. before: ${POSTGRES_NON_ROOT_USER} now: "${POSTGRES_NON_ROOT_USER}" --- docker-compose/withPostgresAndWorker/init-data.sh | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/docker-compose/withPostgresAndWorker/init-data.sh b/docker-compose/withPostgresAndWorker/init-data.sh index f98a972e..c7495053 100755 --- a/docker-compose/withPostgresAndWorker/init-data.sh +++ b/docker-compose/withPostgresAndWorker/init-data.sh @@ -1,13 +1,12 @@ #!/bin/bash -set -e; - +set -e if [ -n "${POSTGRES_NON_ROOT_USER:-}" ] && [ -n "${POSTGRES_NON_ROOT_PASSWORD:-}" ]; then - psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL - CREATE USER ${POSTGRES_NON_ROOT_USER} WITH PASSWORD '${POSTGRES_NON_ROOT_PASSWORD}'; - GRANT ALL PRIVILEGES ON DATABASE ${POSTGRES_DB} TO ${POSTGRES_NON_ROOT_USER}; - GRANT CREATE ON SCHEMA public TO ${POSTGRES_NON_ROOT_USER}; - EOSQL + psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL + CREATE USER "${POSTGRES_NON_ROOT_USER}" WITH ENCRYPTED PASSWORD '${POSTGRES_NON_ROOT_PASSWORD}'; + GRANT ALL PRIVILEGES ON DATABASE ${POSTGRES_DB} TO "${POSTGRES_NON_ROOT_USER}"; + GRANT CREATE ON SCHEMA public TO "${POSTGRES_NON_ROOT_USER}"; +EOSQL else - echo "SETUP INFO: No Environment variables given!" + echo "SETUP INFO: No Environment variables given!" fi