Anpassungen

This commit is contained in:
2026-08-13 06:10:01 -05:00
parent 45f6c4d83b
commit 31cba6d883

54
docker/init-db.sh Normal file → Executable file
View File

@@ -1,26 +1,28 @@
#!/bin/bash #!/bin/bash
set -e set -e
# This script runs when the PostgreSQL container is first created # This script runs when the PostgreSQL container is first created
# It ensures the database is properly initialized # It ensures the database is properly initialized
#
echo "🚀 Initializing QR Master database..." # 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
# Create the database if it doesn't exist (already created by POSTGRES_DB) # the init, and the container never becomes healthy.
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL # Must stay LF-only and executable - Postgres sources non-executable init
-- Enable required extensions # scripts, and CRLF breaks them on the first line.
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
CREATE EXTENSION IF NOT EXISTS "pg_trgm"; echo "🚀 Initializing QR Master database..."
-- Grant privileges # The database itself is already created by POSTGRES_DB
GRANT ALL PRIVILEGES ON DATABASE qrmaster TO postgres; psql -v ON_ERROR_STOP=1 -v dbname="$POSTGRES_DB" --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
-- Enable required extensions
-- Set timezone CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
ALTER DATABASE qrmaster SET timezone TO 'UTC'; CREATE EXTENSION IF NOT EXISTS "pg_trgm";
EOSQL
-- Set timezone
echo "✅ Database initialization complete!" ALTER DATABASE :"dbname" SET timezone TO 'UTC';
echo "📊 Database: $POSTGRES_DB" EOSQL
echo "👤 User: $POSTGRES_USER"
echo "🌐 Ready to accept connections on port 5432" echo "✅ Database initialization complete!"
echo "📊 Database: $POSTGRES_DB"
echo "👤 User: $POSTGRES_USER"
echo "🌐 Ready to accept connections on port 5432"