provisioning: Don't rebuild DB if running migrations is sufficient.

This results in a significant optimization in the performance of
re-provisioning Zulip if all that you're doing is rebasing onto a
newer version of master (which just adds new migrations).

The change carries some risk of generating unpleasant-to-debug
situations, because if we merge a buggy migration and then later fix
it, some clients may not have a properly migrated database (and also,
this changes how populate_db commutes with migrations).  But it seems
worth it, given how much time is currently wasted by not having this.

Fixes: #9512.
This commit is contained in:
Aditya Bansal
2018-06-06 04:38:27 +05:30
committed by Tim Abbott
parent 65dc80fe9d
commit 1205e02c64
2 changed files with 57 additions and 8 deletions

View File

@@ -321,7 +321,7 @@ def main(options):
import django
django.setup()
from zerver.lib.test_fixtures import template_database_status
from zerver.lib.test_fixtures import template_database_status, run_db_migrations
try:
from zerver.lib.queue import SimpleQueueClient
@@ -344,6 +344,8 @@ def main(options):
if options.is_force or dev_template_db_status == 'needs_rebuild':
run(["tools/setup/postgres-init-dev-db"])
run(["tools/do-destroy-rebuild-database"])
elif dev_template_db_status == 'run_migrations':
run_db_migrations('dev')
elif dev_template_db_status == 'current':
print("No need to regenerate the dev DB.")
@@ -351,6 +353,8 @@ def main(options):
if options.is_force or test_template_db_status == 'needs_rebuild':
run(["tools/setup/postgres-init-test-db"])
run(["tools/do-destroy-rebuild-test-database"])
elif test_template_db_status == 'run_migrations':
run_db_migrations('test')
elif test_template_db_status == 'current':
print("No need to regenerate the test DB.")