mirror of
https://github.com/zulip/zulip.git
synced 2025-11-05 06:23:38 +00:00
Drop database users prior to DROP/CREATE database.
This fixes an annoying issue where one tries to rebuild the database, and it fails due to there being existing connections. The one thing that is potentially scary about this implementation is that it means it's now a lot easier to accidentally drop your production database by running the wrong script; might be worth adding a "--force" flag controlling this behavior or something. Thanks to Nemanja Stanarevic and Neeraj Wahi for prototypes of this implementation! They did most of the work and testing for this.
This commit is contained in:
@@ -1,8 +1,14 @@
|
||||
#!/bin/sh -xe
|
||||
#!/bin/bash
|
||||
set -e
|
||||
set -x
|
||||
|
||||
# Make sure the current working directory is readable
|
||||
cd /
|
||||
|
||||
# Drop any open connections to any old database. Hackishly call using
|
||||
# source because postgres user can't read /root/zulip/scripts/setup.
|
||||
source "$(dirname "$0")/terminate-psql-sessions" postgres zulip zulip_base
|
||||
|
||||
su postgres -c psql <<EOF
|
||||
CREATE USER zulip;
|
||||
ALTER ROLE zulip SET search_path TO zulip,public;
|
||||
@@ -15,6 +21,7 @@ CREATE SCHEMA zulip AUTHORIZATION zulip;
|
||||
CREATE EXTENSION tsearch_extras SCHEMA zulip;
|
||||
EOF
|
||||
|
||||
# Clear memcached to avoid contamination from previous database state
|
||||
sh "$(dirname "$0")/flush-memcached"
|
||||
|
||||
echo "Database created"
|
||||
|
||||
Reference in New Issue
Block a user