diff --git a/spiffworkflow-backend/bin/recreate_db b/spiffworkflow-backend/bin/recreate_db index 499762f54..b9ed10401 100755 --- a/spiffworkflow-backend/bin/recreate_db +++ b/spiffworkflow-backend/bin/recreate_db @@ -37,17 +37,19 @@ database_username="root" database_password="" databases_to_run_on="spiffworkflow_backend_local_development spiffworkflow_backend_unit_testing" database_name_from_uri="" -if [[ -n "${SPIFFWORKFLOW_BACKEND_DATABASE_URI:-}" ]]; then - database_host_and_port=$(grep -oP "^[^:]+://.*@\K(.+?)[/]" <<<"$SPIFFWORKFLOW_BACKEND_DATABASE_URI" | sed -E 's/[\/]$//') - database_host=$(awk -F ':' '{print $1}' <<<"$database_host_and_port") - database_port=$(awk -F ':' '{print $2}' <<<"$database_host_and_port") - database_username_and_password=$(grep -oP "^[^:]+://\K([^@]+)[@]" <<<"$SPIFFWORKFLOW_BACKEND_DATABASE_URI" | sed -E 's/[@]$//') - database_username=$(awk -F ':' '{print $1}' <<<"$database_username_and_password") - database_password=$(awk -F ':' '{print $2}' <<<"$database_username_and_password") - database_name_from_uri=$(grep -oP "/\K(\w+)$" <<<"$SPIFFWORKFLOW_BACKEND_DATABASE_URI") - if ! grep "\<$database_name_from_uri\>" <<<"$databases_to_run_on"; then - databases_to_run_on="$database_name_from_uri" - fi +if [[ "${SPIFFWORKFLOW_BACKEND_DATABASE_TYPE:-mysql}" != "sqlite" ]]; then + if [[ -n "${SPIFFWORKFLOW_BACKEND_DATABASE_URI:-}" ]]; then + database_host_and_port=$(grep -oP "^[^:]+://.*@\K(.+?)[/]" <<<"$SPIFFWORKFLOW_BACKEND_DATABASE_URI" | sed -E 's/[\/]$//') + database_host=$(awk -F ':' '{print $1}' <<<"$database_host_and_port") + database_port=$(awk -F ':' '{print $2}' <<<"$database_host_and_port") + database_username_and_password=$(grep -oP "^[^:]+://\K([^@]+)[@]" <<<"$SPIFFWORKFLOW_BACKEND_DATABASE_URI" | sed -E 's/[@]$//') + database_username=$(awk -F ':' '{print $1}' <<<"$database_username_and_password") + database_password=$(awk -F ':' '{print $2}' <<<"$database_username_and_password") + database_name_from_uri=$(grep -oP "/\K(\w+)$" <<<"$SPIFFWORKFLOW_BACKEND_DATABASE_URI") + if ! grep "\<$database_name_from_uri\>" <<<"$databases_to_run_on"; then + databases_to_run_on="$database_name_from_uri" + fi + fi fi database_host_args="-h $database_host -u $database_username"