mirror of
				https://github.com/zulip/zulip.git
				synced 2025-10-31 03:53:50 +00:00 
			
		
		
		
	db tools: Simplify args for postgres-init-dev-db.
We now just have two modes for setting up a dev/test
database.  This makes it easy to see these things
side-by-side, when you're trying to understand how
the two different databases get built:
    # dev:
        USERNAME=zulip
        DBNAME=zulip
        STATUS_FILE_NAME=migration_status_dev
    # test:
        USERNAME=zulip_test
        DBNAME=zulip_test
        STATUS_FILE_NAME=migration_status_test
And then we make it more explicit the things that
are common between dev and test (which are
important things to understand when troubleshooting
provision-related glitches):
    SEARCH_PATH=zulip,public
    PASSWORD=$("$(dirname "$0")/../../scripts/get-django-setting" LOCAL_DATABASE_PASSWORD)
    DBNAME_BASE=${DBNAME}_base
We lose some "generality" here, but passing in arbitrary
combinations of username/dbname/status_file to the script
would cause chaos for our digest checks, and all the different
template/base databases could cause confusion too.
			
			
This commit is contained in:
		| @@ -1,7 +1,32 @@ | ||||
| #!/usr/bin/env bash | ||||
| set -x | ||||
| set -e | ||||
|  | ||||
| if [[ $# == 0 ]]; then | ||||
|     MODE=dev | ||||
| elif [[ $# == 1 ]]; then | ||||
|     MODE=$1 | ||||
| else | ||||
|     echo "Too many arguments" | ||||
|     exit 1 | ||||
| fi | ||||
|  | ||||
| if [[ "$MODE" == "dev" ]]; then | ||||
|     USERNAME=zulip | ||||
|     DBNAME=zulip | ||||
|     STATUS_FILE_NAME=migration_status_dev | ||||
| elif [[ "$MODE" == "test" ]]; then | ||||
|     USERNAME=zulip_test | ||||
|     DBNAME=zulip_test | ||||
|     STATUS_FILE_NAME=migration_status_test | ||||
| else | ||||
|     echo "Usage Instructions" | ||||
|     echo "Run with either no arguments (sets up devel db for local deploy--zulip with user zulip)" | ||||
|     echo "or specify 'test'" | ||||
|     exit 1 | ||||
| fi | ||||
|  | ||||
| set -x | ||||
|  | ||||
| POSTGRES_USER="postgres" | ||||
| if [ "$(uname)" = "OpenBSD" ]; then | ||||
|   POSTGRES_USER="_postgresql" | ||||
| @@ -20,25 +45,8 @@ fi | ||||
|  | ||||
| VAGRANTUSERNAME=$(whoami) | ||||
|  | ||||
| if [[ $# == 0 ]]; then | ||||
|     USERNAME=zulip | ||||
|     PASSWORD=$("$(dirname "$0")/../../scripts/get-django-setting" LOCAL_DATABASE_PASSWORD) | ||||
|     DBNAME=zulip | ||||
|     SEARCH_PATH="$USERNAME",public | ||||
|     STATUS_FILE_NAME="migration_status_dev" | ||||
| elif [[ $# == 5 ]]; then | ||||
|     USERNAME=$1 | ||||
|     PASSWORD=$2 | ||||
|     DBNAME=$3 | ||||
|     SEARCH_PATH=$4 | ||||
|     STATUS_FILE_NAME=$5 | ||||
| else | ||||
|     echo "Usage Instructions" | ||||
|     echo "Run with either no arguments (sets up devel db for local deploy--zulip with user zulip)" | ||||
|     echo "or specify <db-username> <password> <db-name> <user-schema-search-path> <migration-status-path>" | ||||
|     exit | ||||
| fi | ||||
|  | ||||
| SEARCH_PATH=zulip,public | ||||
| PASSWORD=$("$(dirname "$0")/../../scripts/get-django-setting" LOCAL_DATABASE_PASSWORD) | ||||
| DBNAME_BASE=${DBNAME}_base | ||||
|  | ||||
| if ! pg_isready -U "$POSTGRES_USER" -q; then | ||||
|   | ||||
| @@ -2,4 +2,4 @@ | ||||
| set -x | ||||
| set -e | ||||
|  | ||||
| "$(dirname "$0")/postgres-init-dev-db" zulip_test "$("$(dirname "$0")/../../scripts/get-django-setting" LOCAL_DATABASE_PASSWORD)" zulip_test zulip,public migration_status_test | ||||
| "$(dirname "$0")/postgres-init-dev-db" test | ||||
|   | ||||
		Reference in New Issue
	
	Block a user