Skip to content

Commit

Permalink
Changed recreate_db to skip non sqlite attributes (#2168)
Browse files Browse the repository at this point in the history
* Changed recreate_db to skip non sqlite attributes

* reverted package-lock.json

* reverted poetry.lock

* reverted pyproject.toml

* reverted frontend config.tsx and vite.config.ts

* Removed my personal debugging echo statements from recreate_db
  • Loading branch information
twentyninehairs authored Dec 4, 2024
1 parent bdb010f commit 7cd38a3
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions spiffworkflow-backend/bin/recreate_db
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 7cd38a3

Please sign in to comment.