You've already forked testing-go-code-with-postgres
mirror of
https://github.com/xorcare/testing-go-code-with-postgres.git
synced 2025-06-30 23:23:40 +02:00
Publish an example testing go code with Postgres
This commit is contained in:
20
docker-multiple-databases.sh
Executable file
20
docker-multiple-databases.sh
Executable file
@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
set -u
|
||||
|
||||
function create_user_and_database() {
|
||||
local database=$1
|
||||
echo " Creating user and database '$database'"
|
||||
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" <<-EOSQL
|
||||
CREATE DATABASE $database OWNER $POSTGRES_USER;
|
||||
EOSQL
|
||||
}
|
||||
|
||||
if [ -n "$POSTGRES_MULTIPLE_DATABASES" ]; then
|
||||
echo "Multiple database creation requested: $POSTGRES_MULTIPLE_DATABASES"
|
||||
for database in $(echo "$POSTGRES_MULTIPLE_DATABASES" | tr ',' ' '); do
|
||||
create_user_and_database "$database"
|
||||
done
|
||||
echo "Multiple databases created"
|
||||
fi
|
Reference in New Issue
Block a user