From 31cba6d883cdfb3fb99a728a3c38fb61997f1bc9 Mon Sep 17 00:00:00 2001 From: Andreas Knuth Date: Thu, 13 Aug 2026 06:10:01 -0500 Subject: [PATCH] Anpassungen --- docker/init-db.sh | 54 ++++++++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 26 deletions(-) mode change 100644 => 100755 docker/init-db.sh diff --git a/docker/init-db.sh b/docker/init-db.sh old mode 100644 new mode 100755 index 57f56a8..c3e8d25 --- a/docker/init-db.sh +++ b/docker/init-db.sh @@ -1,26 +1,28 @@ -#!/bin/bash -set -e - -# This script runs when the PostgreSQL container is first created -# It ensures the database is properly initialized - -echo "🚀 Initializing QR Master database..." - -# Create the database if it doesn't exist (already created by POSTGRES_DB) -psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL - -- Enable required extensions - CREATE EXTENSION IF NOT EXISTS "uuid-ossp"; - CREATE EXTENSION IF NOT EXISTS "pg_trgm"; - - -- Grant privileges - GRANT ALL PRIVILEGES ON DATABASE qrmaster TO postgres; - - -- Set timezone - ALTER DATABASE qrmaster SET timezone TO 'UTC'; -EOSQL - -echo "✅ Database initialization complete!" -echo "📊 Database: $POSTGRES_DB" -echo "👤 User: $POSTGRES_USER" -echo "🌐 Ready to accept connections on port 5432" - +#!/bin/bash +set -e + +# This script runs when the PostgreSQL container is first created +# It ensures the database is properly initialized +# +# Keep this database-name agnostic: the staging stack (docker-compose.test.yml) +# runs the same script with POSTGRES_DB=qrmaster_test. A hardcoded name aborts +# the init, and the container never becomes healthy. +# Must stay LF-only and executable - Postgres sources non-executable init +# scripts, and CRLF breaks them on the first line. + +echo "🚀 Initializing QR Master database..." + +# The database itself is already created by POSTGRES_DB +psql -v ON_ERROR_STOP=1 -v dbname="$POSTGRES_DB" --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL + -- Enable required extensions + CREATE EXTENSION IF NOT EXISTS "uuid-ossp"; + CREATE EXTENSION IF NOT EXISTS "pg_trgm"; + + -- Set timezone + ALTER DATABASE :"dbname" SET timezone TO 'UTC'; +EOSQL + +echo "✅ Database initialization complete!" +echo "📊 Database: $POSTGRES_DB" +echo "👤 User: $POSTGRES_USER" +echo "🌐 Ready to accept connections on port 5432"