Merge pull request #16851 from edx/estute/paver-fingerprint-migrations

TE-2350 paver function to fingerprint bokchoy db files
This commit is contained in:
Stu Young
2017-12-13 12:20:08 -05:00
committed by GitHub
2 changed files with 99 additions and 1 deletions

View File

@@ -0,0 +1,39 @@
#!/usr/bin/env bash
############################################################################
#
# Output all migrations that would be applied to an
# empty database for the bok-choy acceptance tests.
#
############################################################################
# Fail fast
set -e
if [[ -z "$BOK_CHOY_HOSTNAME" ]]; then
MYSQL_HOST=""
SETTINGS="bok_choy"
else
MYSQL_HOST="--host=edx.devstack.mysql"
SETTINGS="bok_choy_docker"
fi
declare -A databases
declare -a database_order
databases=(["default"]="edxtest" ["student_module_history"]="student_module_history_test")
database_order=("default" "student_module_history")
for db in "${database_order[@]}"; do
echo "CREATE DATABASE IF NOT EXISTS ${databases[$db]};" | mysql $MYSQL_HOST -u root
# Clear out the test database using the reset_db command which uses "DROP DATABASE" and
# "CREATE DATABASE". This will result in an empty database.
echo "Clearing out the $db bok_choy MySQL database."
./manage.py lms --settings $SETTINGS reset_db --traceback --router $db
# Now output all the migrations in the platform to a file.
echo "Calculating migrations."
output_file="common/test/db_cache/bok_choy_${db}_migrations.yaml"
./manage.py lms --settings $SETTINGS show_unapplied_migrations --database $db --output_file $output_file
done