Fix user existence check and add PGPASSWORD for app user during deploy

This commit is contained in:
Paul Trowbridge 2026-03-28 01:16:45 -04:00
parent 7abecc99ea
commit 06e002931d

View File

@ -69,7 +69,7 @@ fi
# Create user if it doesn't exist
echo ""
echo "👤 Creating PostgreSQL user..."
if psql -U "$ADMIN_USER" -h "$DB_HOST" -p "$DB_PORT" -d postgres -tc "SELECT 1 FROM pg_roles WHERE rolname='$APP_USER'" | grep -q 1; then
if psql -U "$ADMIN_USER" -h "$DB_HOST" -p "$DB_PORT" -d postgres -tAc "SELECT rolname FROM pg_roles WHERE rolname='$APP_USER'" | grep -q "^$APP_USER$"; then
echo "✓ User '$APP_USER' already exists"
else
psql -U "$ADMIN_USER" -h "$DB_HOST" -p "$DB_PORT" -d postgres -c "CREATE USER $APP_USER WITH PASSWORD '$APP_PASS';"
@ -88,6 +88,9 @@ fi
unset PGPASSWORD
# Set password for app user
export PGPASSWORD="$APP_PASS"
# Save credentials to .env
echo ""
echo "💾 Saving credentials to .env..."