mirror of https://github.com/zulip/zulip.git
tools: Fix postgres-init-*-db cache handling.
Previously, it didn't properly update the stamp files that determine our caching behavior, so if one ran test-backend afterwards, nothing would happen. A secondary issue that this commit does not fix is that provision will end up rerunning the whole thing.
This commit is contained in:
parent
544f9c74ce
commit
9760c8cfc9
|
@ -140,11 +140,6 @@ def make_deploy_path():
|
||||||
timestamp = datetime.datetime.now().strftime(TIMESTAMP_FORMAT)
|
timestamp = datetime.datetime.now().strftime(TIMESTAMP_FORMAT)
|
||||||
return os.path.join(DEPLOYMENTS_DIR, timestamp)
|
return os.path.join(DEPLOYMENTS_DIR, timestamp)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
cmd = sys.argv[1]
|
|
||||||
if cmd == 'make_deploy_path':
|
|
||||||
print(make_deploy_path())
|
|
||||||
|
|
||||||
TEMPLATE_DATABASE_DIR = "test-backend/databases"
|
TEMPLATE_DATABASE_DIR = "test-backend/databases"
|
||||||
def get_dev_uuid_var_path(create_if_missing=False):
|
def get_dev_uuid_var_path(create_if_missing=False):
|
||||||
# type: (bool) -> str
|
# type: (bool) -> str
|
||||||
|
@ -477,3 +472,10 @@ def get_or_create_dev_uuid_var_path(path: str) -> str:
|
||||||
absolute_path = '{}/{}'.format(get_dev_uuid_var_path(), path)
|
absolute_path = '{}/{}'.format(get_dev_uuid_var_path(), path)
|
||||||
os.makedirs(absolute_path, exist_ok=True)
|
os.makedirs(absolute_path, exist_ok=True)
|
||||||
return absolute_path
|
return absolute_path
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
cmd = sys.argv[1]
|
||||||
|
if cmd == 'make_deploy_path':
|
||||||
|
print(make_deploy_path())
|
||||||
|
elif cmd == 'get_dev_uuid':
|
||||||
|
print(get_dev_uuid_var_path())
|
||||||
|
|
|
@ -25,15 +25,17 @@ if [[ $# == 0 ]]; then
|
||||||
PASSWORD=$("$(dirname "$0")/../../scripts/get-django-setting" LOCAL_DATABASE_PASSWORD)
|
PASSWORD=$("$(dirname "$0")/../../scripts/get-django-setting" LOCAL_DATABASE_PASSWORD)
|
||||||
DBNAME=zulip
|
DBNAME=zulip
|
||||||
SEARCH_PATH="$USERNAME",public
|
SEARCH_PATH="$USERNAME",public
|
||||||
elif [[ $# == 4 ]]; then
|
STATUS_FILE_NAME="migration_status_dev"
|
||||||
|
elif [[ $# == 5 ]]; then
|
||||||
USERNAME=$1
|
USERNAME=$1
|
||||||
PASSWORD=$2
|
PASSWORD=$2
|
||||||
DBNAME=$3
|
DBNAME=$3
|
||||||
SEARCH_PATH=$4
|
SEARCH_PATH=$4
|
||||||
|
STATUS_FILE_NAME=$5
|
||||||
else
|
else
|
||||||
echo "Usage Instructions"
|
echo "Usage Instructions"
|
||||||
echo "Run with either no arguments (sets up devel db for local deploy--zulip with user zulip)"
|
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>"
|
echo "or specify <db-username> <password> <db-name> <user-schema-search-path> <migration-status-path>"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -49,6 +51,11 @@ if ! pg_isready -U "$POSTGRES_USER" -q; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# We need to remove the stamp file indicating that the database
|
||||||
|
# is properly provisioned with migrations.
|
||||||
|
uuid_var_path=$($(readlink -f "$(dirname "$0")/../../scripts/lib/zulip_tools.py") get_dev_uuid)
|
||||||
|
rm -f "$uuid_var_path/$STATUS_FILE_NAME"
|
||||||
|
|
||||||
"${ROOT_POSTGRES[@]}" -v ON_ERROR_STOP=1 -e "$DEFAULT_DB" << EOF
|
"${ROOT_POSTGRES[@]}" -v ON_ERROR_STOP=1 -e "$DEFAULT_DB" << EOF
|
||||||
DO \$\$BEGIN
|
DO \$\$BEGIN
|
||||||
CREATE USER $USERNAME;
|
CREATE USER $USERNAME;
|
||||||
|
|
|
@ -2,4 +2,4 @@
|
||||||
set -x
|
set -x
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
"$(dirname "$0")/postgres-init-dev-db" zulip_test "$("$(dirname "$0")/../../scripts/get-django-setting" LOCAL_DATABASE_PASSWORD)" zulip_test zulip,public
|
"$(dirname "$0")/postgres-init-dev-db" zulip_test "$("$(dirname "$0")/../../scripts/get-django-setting" LOCAL_DATABASE_PASSWORD)" zulip_test zulip,public migration_status_test
|
||||||
|
|
Loading…
Reference in New Issue