2022-05-16 20:38:48 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
function error_handler() {
|
|
|
|
>&2 echo "Exited with BAD EXIT CODE '${2}' in ${0} script at line: ${1}."
|
|
|
|
exit "$2"
|
|
|
|
}
|
|
|
|
trap 'error_handler ${LINENO} $?' ERR
|
|
|
|
set -o errtrace -o errexit -o nounset -o pipefail
|
|
|
|
|
2022-05-17 20:35:38 +00:00
|
|
|
tasks=""
|
|
|
|
if [[ "${1:-}" == "clean" ]]; then
|
2022-05-20 20:37:23 +00:00
|
|
|
if [[ "${2:-}" == "rmall" ]]; then
|
|
|
|
tasks="$tasks init migrate"
|
|
|
|
rm -rf migrations/
|
|
|
|
fi
|
2022-05-16 20:38:48 +00:00
|
|
|
|
2022-05-20 18:30:11 +00:00
|
|
|
rm -f ./src/spiff_workflow_webapp/db*.sqlite3
|
2022-05-20 18:25:12 +00:00
|
|
|
mysql -uroot -e "DROP DATABASE IF EXISTS spiff_workflow_webapp_development"
|
|
|
|
mysql -uroot -e "CREATE DATABASE spiff_workflow_webapp_development"
|
|
|
|
mysql -uroot -e "DROP DATABASE IF EXISTS spiff_workflow_webapp_testing"
|
|
|
|
mysql -uroot -e "CREATE DATABASE spiff_workflow_webapp_testing"
|
2022-05-17 20:35:38 +00:00
|
|
|
fi
|
2022-05-20 20:37:23 +00:00
|
|
|
tasks="$tasks upgrade"
|
2022-05-17 20:35:38 +00:00
|
|
|
|
|
|
|
for task in $tasks ; do
|
2022-05-16 20:38:48 +00:00
|
|
|
FLASK_ENV=development FLASK_APP=src/spiff_workflow_webapp poetry run flask db "$task"
|
|
|
|
done
|
2022-05-19 18:38:47 +00:00
|
|
|
|
|
|
|
FLASK_ENV=testing FLASK_APP=src/spiff_workflow_webapp poetry run flask db upgrade
|