diff --git a/tools/setup/postgres-init-dev-db b/tools/setup/postgres-init-dev-db index 198a7e7f5c..940de6ab39 100755 --- a/tools/setup/postgres-init-dev-db +++ b/tools/setup/postgres-init-dev-db @@ -50,12 +50,20 @@ if ! pg_isready -U "$POSTGRES_USER" -q; then fi "${ROOT_POSTGRES[@]}" "$DEFAULT_DB" << EOF -CREATE USER $USERNAME; +DO \$\$BEGIN + CREATE USER $USERNAME; +EXCEPTION WHEN duplicate_object THEN + RAISE NOTICE '$USERNAME user already exists'; +END\$\$; ALTER USER $USERNAME PASSWORD '$PASSWORD'; ALTER USER $USERNAME CREATEDB; ALTER ROLE $USERNAME SET search_path TO $SEARCH_PATH; -CREATE USER $VAGRANTUSERNAME; +DO \$\$BEGIN + 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; EOF