mirror of https://github.com/zulip/zulip.git
postgres-init-dev-db: Catch exception when recreating extant users.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
This commit is contained in:
parent
25798c8605
commit
efd22fd2ae
|
@ -50,12 +50,20 @@ if ! pg_isready -U "$POSTGRES_USER" -q; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
"${ROOT_POSTGRES[@]}" "$DEFAULT_DB" << EOF
|
"${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 PASSWORD '$PASSWORD';
|
||||||
ALTER USER $USERNAME CREATEDB;
|
ALTER USER $USERNAME CREATEDB;
|
||||||
ALTER ROLE $USERNAME SET search_path TO $SEARCH_PATH;
|
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;
|
GRANT $USERNAME TO $VAGRANTUSERNAME;
|
||||||
ALTER ROLE $VAGRANTUSERNAME SET search_path TO $SEARCH_PATH;
|
ALTER ROLE $VAGRANTUSERNAME SET search_path TO $SEARCH_PATH;
|
||||||
EOF
|
EOF
|
||||||
|
|
Loading…
Reference in New Issue