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-06-03 14:56:07 +00:00
|
|
|
export FLASK_SESSION_SECRET_KEY="this_is_recreate_db_secret_key"
|
|
|
|
|
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-06-01 15:17:25 +00:00
|
|
|
rm -f ./src/spiffworkflow_backend/db*.sqlite3
|
|
|
|
mysql -uroot -e "DROP DATABASE IF EXISTS spiffworkflow_backend_development"
|
|
|
|
mysql -uroot -e "DROP DATABASE IF EXISTS spiffworkflow_backend_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
|
|
|
|
2022-06-08 14:07:25 +00:00
|
|
|
mysql -uroot -e "CREATE DATABASE IF NOT EXISTS spiffworkflow_backend_development"
|
|
|
|
mysql -uroot -e "CREATE DATABASE IF NOT EXISTS spiffworkflow_backend_testing"
|
|
|
|
|
2022-05-17 20:35:38 +00:00
|
|
|
for task in $tasks ; do
|
2022-06-01 15:17:25 +00:00
|
|
|
FLASK_ENV=development FLASK_APP=src/spiffworkflow_backend poetry run flask db "$task"
|
2022-05-16 20:38:48 +00:00
|
|
|
done
|
2022-05-19 18:38:47 +00:00
|
|
|
|
2022-06-01 15:17:25 +00:00
|
|
|
FLASK_ENV=testing FLASK_APP=src/spiffworkflow_backend poetry run flask db upgrade
|