mirror of
https://github.com/zulip/zulip.git
synced 2025-11-05 06:23:38 +00:00
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:
@@ -4,6 +4,10 @@ set -x
|
|||||||
|
|
||||||
"$(dirname "$0")/../scripts/setup/terminate-psql-sessions" zulip zulip zulip_base
|
"$(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
|
psql -h localhost postgres zulip <<EOF
|
||||||
DROP DATABASE IF EXISTS zulip;
|
DROP DATABASE IF EXISTS zulip;
|
||||||
CREATE DATABASE zulip TEMPLATE zulip_base;
|
CREATE DATABASE zulip TEMPLATE zulip_base;
|
||||||
@@ -12,6 +16,7 @@ EOF
|
|||||||
sh "$(dirname "$0")/../scripts/setup/flush-memcached"
|
sh "$(dirname "$0")/../scripts/setup/flush-memcached"
|
||||||
|
|
||||||
./manage.py migrate --noinput
|
./manage.py migrate --noinput
|
||||||
|
migration_status "var/migration_status_dev"
|
||||||
./manage.py createcachetable third_party_api_results
|
./manage.py createcachetable third_party_api_results
|
||||||
./manage.py populate_db -n100 --threads=1
|
./manage.py populate_db -n100 --threads=1
|
||||||
# Ensure that the local user's API key is synced from ~/.zuliprc
|
# Ensure that the local user's API key is synced from ~/.zuliprc
|
||||||
|
|||||||
@@ -240,18 +240,28 @@ def main(options):
|
|||||||
if not options.is_production_travis:
|
if not options.is_production_travis:
|
||||||
# These won't be used anyway
|
# These won't be used anyway
|
||||||
run(["scripts/setup/configure-rabbitmq"])
|
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.
|
# Need to set up Django before using is_template_database_current.
|
||||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "zproject.settings")
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "zproject.settings")
|
||||||
import django
|
import django
|
||||||
django.setup()
|
django.setup()
|
||||||
from zerver.lib.test_fixtures import is_template_database_current
|
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():
|
if options.is_force or not is_template_database_current():
|
||||||
run(["tools/setup/postgres-init-test-db"])
|
run(["tools/setup/postgres-init-test-db"])
|
||||||
run(["tools/do-destroy-rebuild-test-database"])
|
run(["tools/do-destroy-rebuild-test-database"])
|
||||||
else:
|
else:
|
||||||
print("No need to regenerate the test DB.")
|
print("No need to regenerate the test DB.")
|
||||||
|
|
||||||
run(["./manage.py", "compilemessages"])
|
run(["./manage.py", "compilemessages"])
|
||||||
|
|
||||||
# Here we install nvm, node, and npm.
|
# Here we install nvm, node, and npm.
|
||||||
|
|||||||
Reference in New Issue
Block a user