diff --git a/scripts/setup/upgrade-postgresql b/scripts/setup/upgrade-postgresql index 35d4ee6c57..f8d91bf710 100755 --- a/scripts/setup/upgrade-postgresql +++ b/scripts/setup/upgrade-postgresql @@ -26,6 +26,27 @@ if [[ "$UPGRADE_TO" -lt "$UPGRADE_FROM" ]]; then exit 1 fi +# Verify that the version in /etc/zulip/zulip.conf is the version that +# Django actually stores its data in. We can only do that if the +# database server is on the same host as the application server. +if [ -d /home/zulip/deployments/current ]; then + DATA_IS_IN=$(su zulip -c '/home/zulip/deployments/current/manage.py shell -c "from django.db import connection; print(int(connection.cursor().connection.server_version/10000))"') + + if [ "$UPGRADE_FROM" != "$DATA_IS_IN" ]; then + cat <