provision: Don't regenerate dev database unnecessarily.

This reuses the work we did some time ago to avoid regenerating the
test database unnecessarily.

In addition to being a nice convenience for developers (since any
accomulated test data is still available), this also saves about half
the time consumed in a no-op provision.

Fixes #5182.
This commit is contained in:
Tim Abbott 2017-06-02 12:50:24 -07:00
parent a0ef2babab
commit cecf7f1740
2 changed files with 17 additions and 2 deletions

View File

@ -4,6 +4,10 @@ set -x
"$(dirname "$0")/../scripts/setup/terminate-psql-sessions" zulip zulip zulip_base
function migration_status {
./manage.py get_migration_status --settings=zproject.settings > $1
}
psql -h localhost postgres zulip <<EOF
DROP DATABASE IF EXISTS zulip;
CREATE DATABASE zulip TEMPLATE zulip_base;
@ -12,6 +16,7 @@ EOF
sh "$(dirname "$0")/../scripts/setup/flush-memcached"
./manage.py migrate --noinput
migration_status "var/migration_status_dev"
./manage.py createcachetable third_party_api_results
./manage.py populate_db -n100 --threads=1
# Ensure that the local user's API key is synced from ~/.zuliprc

View File

@ -240,18 +240,28 @@ def main(options):
if not options.is_production_travis:
# These won't be used anyway
run(["scripts/setup/configure-rabbitmq"])
run(["tools/setup/postgres-init-dev-db"])
run(["tools/do-destroy-rebuild-database"])
# Need to set up Django before using is_template_database_current.
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "zproject.settings")
import django
django.setup()
from zerver.lib.test_fixtures import is_template_database_current
if options.is_force or not is_template_database_current(
migration_status="var/migration_status_dev",
settings="zproject.settings",
database_name="zulip",
):
run(["tools/setup/postgres-init-dev-db"])
run(["tools/do-destroy-rebuild-database"])
else:
print("No need to regenerate the dev DB.")
if options.is_force or not is_template_database_current():
run(["tools/setup/postgres-init-test-db"])
run(["tools/do-destroy-rebuild-test-database"])
else:
print("No need to regenerate the test DB.")
run(["./manage.py", "compilemessages"])
# Here we install nvm, node, and npm.