migration_status: Switch to passing the path in Python.

This is an important prerequisite to changing these paths used in
provisioning.
This commit is contained in:
Tim Abbott 2017-10-17 19:39:55 -07:00
parent a7c639cff7
commit b7c3b4df0c
3 changed files with 12 additions and 11 deletions

View File

@ -4,10 +4,6 @@ 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;
@ -17,7 +13,7 @@ sh "$(dirname "$0")/../scripts/setup/flush-memcached"
./manage.py purge_queue --all
./manage.py migrate --noinput
migration_status "var/migration_status_dev"
./manage.py get_migration_status --settings=zproject.settings --output="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

@ -1,10 +1,6 @@
#!/usr/bin/env bash
set -e
function migration_status {
./manage.py get_migration_status --settings=zproject.test_settings > $1
}
if [ "$1" != "--force" ]; then
"$(dirname "$0")/../../scripts/setup/terminate-psql-sessions" zulip zulip_test zulip_test_base zulip_test_template
psql -h localhost postgres zulip_test << EOF
@ -26,7 +22,8 @@ EOF
sh "$(dirname "$0")/../../scripts/setup/flush-memcached"
./manage.py migrate --noinput --settings=zproject.test_settings
migration_status "var/migration_status_test"
./manage.py get_migration_status --settings=zproject.test_settings \
--output="var/migration_status_test"
# This next line can be simplified to "-n0" once we fix our app (and tests) with 0 messages.
./manage.py populate_db --settings=zproject.test_settings --test-suite -n30 \

View File

@ -19,6 +19,14 @@ class Command(BaseCommand):
default=DEFAULT_DB_ALIAS, help='Nominates a database to synchronize. '
'Defaults to the "default" database.')
parser.add_argument('--output', action='store',
help='Path to store the status to (default to stdout).')
def handle(self, *args, **options):
# type: (*Any, **Any) -> None
self.stdout.write(get_migration_status(**options))
result = get_migration_status(**options)
if options['output'] is not None:
with open(options['output'], 'w') as f:
f.write(result)
else:
self.stdout.write(result)