postgresql-init-dev-db: Fix string quotes.

The previous version of the script did not quote VAGRANTUSERNAME, which caused 
an error when running the script if the username contained `-` or other characters
that affect the Postgres syntax. Fix this using double-quotes.
This commit is contained in:
Gyan Dev 2024-01-19 23:02:14 +05:30 committed by GitHub
parent 684101353f
commit 59996ff353
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 3 deletions

View File

@ -75,12 +75,12 @@ ALTER USER $USERNAME CREATEDB;
ALTER ROLE $USERNAME SET search_path TO $SEARCH_PATH;
DO \$\$BEGIN
CREATE USER $VAGRANTUSERNAME;
CREATE USER "$VAGRANTUSERNAME";
EXCEPTION WHEN duplicate_object THEN
RAISE NOTICE '$VAGRANTUSERNAME user already exists';
END\$\$;
GRANT $USERNAME TO $VAGRANTUSERNAME;
ALTER ROLE $VAGRANTUSERNAME SET search_path TO $SEARCH_PATH;
GRANT $USERNAME TO "$VAGRANTUSERNAME";
ALTER ROLE "$VAGRANTUSERNAME" SET search_path TO $SEARCH_PATH;
EOF
umask go-rw