Skip to content

Commit

Permalink
Fix issue with multiple schema creation and modify existing tests (ka…
Browse files Browse the repository at this point in the history
  • Loading branch information
jyrkka authored Oct 2, 2023
1 parent 98f3c97 commit 1468f48
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions scenario_tests/multiple_databases/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ services:
POSTGRES_DB: 'gis,data'
POSTGRES_PASS: 'docker'
ALL_DATABASES: TRUE
SCHEMA_NAME: demo
SCHEMA_NAME: 'demo1,demo2'
healthcheck:
interval: 60s
timeout: 30s
Expand All @@ -40,7 +40,7 @@ services:
POSTGRES_DB: 'gis,data'
POSTGRES_PASS: 'docker'
ALL_DATABASES: FALSE
SCHEMA_NAME: demo
SCHEMA_NAME: 'demo1,demo2'
healthcheck:
interval: 60s
timeout: 30s
Expand Down
4 changes: 3 additions & 1 deletion scripts/setup-database.sh
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,9 @@ done

# Create schemas in the DB
for db in "${dbarr[@]}";do
for schema in $(echo "${SCHEMA_NAME}" | tr ',' ' '); do
IFS=','
read -a schema_arr <<< "$SCHEMA_NAME"
for schema in "${schema_arr[@]}";do
SCHEMA_RESULT=$(psql -t "${db}" -U "${POSTGRES_USER}" -p 5432 -h localhost -c "select count(1) from information_schema.schemata where schema_name = '${schema}' and catalog_name = '${db}';")
if [[ ${SCHEMA_RESULT} -eq 0 ]] && [[ "${ALL_DATABASES}" =~ [Ff][Aa][Ll][Ss][Ee] ]]; then
echo -e "\e[32m [Entrypoint] Creating schema \e[1;31m ${schema} \e[32m in database \e[1;31m ${SINGLE_DB} \033[0m"
Expand Down

0 comments on commit 1468f48

Please sign in to comment.