File tree 13 files changed +39
-13
lines changed
13 files changed +39
-13
lines changed Original file line number Diff line number Diff line change @@ -188,7 +188,9 @@ docker_process_sql() {
188
188
# create initial database
189
189
# uses environment variables for input: POSTGRES_DB
190
190
docker_setup_db () {
191
- if [ " $POSTGRES_DB " != ' postgres' ]; then
191
+ local dbAlreadyExists
192
+ dbAlreadyExists=" $( POSTGRES_DB= docker_process_sql --dbname postgres --set db=" $POSTGRES_DB " --tuples-only --command ' SELECT 1 FROM pg_database WHERE datname = :"db"' ) "
193
+ if [ -z " $dbAlreadyExists " ]; then
192
194
POSTGRES_DB= docker_process_sql --dbname postgres --set db=" $POSTGRES_DB " << -'EOSQL '
193
195
CREATE DATABASE :"db" ;
194
196
EOSQL
Original file line number Diff line number Diff line change @@ -188,7 +188,9 @@ docker_process_sql() {
188
188
# create initial database
189
189
# uses environment variables for input: POSTGRES_DB
190
190
docker_setup_db () {
191
- if [ " $POSTGRES_DB " != ' postgres' ]; then
191
+ local dbAlreadyExists
192
+ dbAlreadyExists=" $( POSTGRES_DB= docker_process_sql --dbname postgres --set db=" $POSTGRES_DB " --tuples-only --command ' SELECT 1 FROM pg_database WHERE datname = :"db"' ) "
193
+ if [ -z " $dbAlreadyExists " ]; then
192
194
POSTGRES_DB= docker_process_sql --dbname postgres --set db=" $POSTGRES_DB " << -'EOSQL '
193
195
CREATE DATABASE :"db" ;
194
196
EOSQL
Original file line number Diff line number Diff line change @@ -188,7 +188,9 @@ docker_process_sql() {
188
188
# create initial database
189
189
# uses environment variables for input: POSTGRES_DB
190
190
docker_setup_db () {
191
- if [ " $POSTGRES_DB " != ' postgres' ]; then
191
+ local dbAlreadyExists
192
+ dbAlreadyExists=" $( POSTGRES_DB= docker_process_sql --dbname postgres --set db=" $POSTGRES_DB " --tuples-only --command ' SELECT 1 FROM pg_database WHERE datname = :"db"' ) "
193
+ if [ -z " $dbAlreadyExists " ]; then
192
194
POSTGRES_DB= docker_process_sql --dbname postgres --set db=" $POSTGRES_DB " << -'EOSQL '
193
195
CREATE DATABASE :"db" ;
194
196
EOSQL
Original file line number Diff line number Diff line change @@ -188,7 +188,9 @@ docker_process_sql() {
188
188
# create initial database
189
189
# uses environment variables for input: POSTGRES_DB
190
190
docker_setup_db () {
191
- if [ " $POSTGRES_DB " != ' postgres' ]; then
191
+ local dbAlreadyExists
192
+ dbAlreadyExists=" $( POSTGRES_DB= docker_process_sql --dbname postgres --set db=" $POSTGRES_DB " --tuples-only --command ' SELECT 1 FROM pg_database WHERE datname = :"db"' ) "
193
+ if [ -z " $dbAlreadyExists " ]; then
192
194
POSTGRES_DB= docker_process_sql --dbname postgres --set db=" $POSTGRES_DB " << -'EOSQL '
193
195
CREATE DATABASE :"db" ;
194
196
EOSQL
Original file line number Diff line number Diff line change @@ -188,7 +188,9 @@ docker_process_sql() {
188
188
# create initial database
189
189
# uses environment variables for input: POSTGRES_DB
190
190
docker_setup_db () {
191
- if [ " $POSTGRES_DB " != ' postgres' ]; then
191
+ local dbAlreadyExists
192
+ dbAlreadyExists=" $( POSTGRES_DB= docker_process_sql --dbname postgres --set db=" $POSTGRES_DB " --tuples-only --command ' SELECT 1 FROM pg_database WHERE datname = :"db"' ) "
193
+ if [ -z " $dbAlreadyExists " ]; then
192
194
POSTGRES_DB= docker_process_sql --dbname postgres --set db=" $POSTGRES_DB " << -'EOSQL '
193
195
CREATE DATABASE :"db" ;
194
196
EOSQL
Original file line number Diff line number Diff line change @@ -188,7 +188,9 @@ docker_process_sql() {
188
188
# create initial database
189
189
# uses environment variables for input: POSTGRES_DB
190
190
docker_setup_db () {
191
- if [ " $POSTGRES_DB " != ' postgres' ]; then
191
+ local dbAlreadyExists
192
+ dbAlreadyExists=" $( POSTGRES_DB= docker_process_sql --dbname postgres --set db=" $POSTGRES_DB " --tuples-only --command ' SELECT 1 FROM pg_database WHERE datname = :"db"' ) "
193
+ if [ -z " $dbAlreadyExists " ]; then
192
194
POSTGRES_DB= docker_process_sql --dbname postgres --set db=" $POSTGRES_DB " << -'EOSQL '
193
195
CREATE DATABASE :"db" ;
194
196
EOSQL
Original file line number Diff line number Diff line change @@ -188,7 +188,9 @@ docker_process_sql() {
188
188
# create initial database
189
189
# uses environment variables for input: POSTGRES_DB
190
190
docker_setup_db () {
191
- if [ " $POSTGRES_DB " != ' postgres' ]; then
191
+ local dbAlreadyExists
192
+ dbAlreadyExists=" $( POSTGRES_DB= docker_process_sql --dbname postgres --set db=" $POSTGRES_DB " --tuples-only --command ' SELECT 1 FROM pg_database WHERE datname = :"db"' ) "
193
+ if [ -z " $dbAlreadyExists " ]; then
192
194
POSTGRES_DB= docker_process_sql --dbname postgres --set db=" $POSTGRES_DB " << -'EOSQL '
193
195
CREATE DATABASE :"db" ;
194
196
EOSQL
Original file line number Diff line number Diff line change @@ -188,7 +188,9 @@ docker_process_sql() {
188
188
# create initial database
189
189
# uses environment variables for input: POSTGRES_DB
190
190
docker_setup_db () {
191
- if [ " $POSTGRES_DB " != ' postgres' ]; then
191
+ local dbAlreadyExists
192
+ dbAlreadyExists=" $( POSTGRES_DB= docker_process_sql --dbname postgres --set db=" $POSTGRES_DB " --tuples-only --command ' SELECT 1 FROM pg_database WHERE datname = :"db"' ) "
193
+ if [ -z " $dbAlreadyExists " ]; then
192
194
POSTGRES_DB= docker_process_sql --dbname postgres --set db=" $POSTGRES_DB " << -'EOSQL '
193
195
CREATE DATABASE :"db" ;
194
196
EOSQL
Original file line number Diff line number Diff line change @@ -188,7 +188,9 @@ docker_process_sql() {
188
188
# create initial database
189
189
# uses environment variables for input: POSTGRES_DB
190
190
docker_setup_db () {
191
- if [ " $POSTGRES_DB " != ' postgres' ]; then
191
+ local dbAlreadyExists
192
+ dbAlreadyExists=" $( POSTGRES_DB= docker_process_sql --dbname postgres --set db=" $POSTGRES_DB " --tuples-only --command ' SELECT 1 FROM pg_database WHERE datname = :"db"' ) "
193
+ if [ -z " $dbAlreadyExists " ]; then
192
194
POSTGRES_DB= docker_process_sql --dbname postgres --set db=" $POSTGRES_DB " << -'EOSQL '
193
195
CREATE DATABASE :"db" ;
194
196
EOSQL
Original file line number Diff line number Diff line change @@ -188,7 +188,9 @@ docker_process_sql() {
188
188
# create initial database
189
189
# uses environment variables for input: POSTGRES_DB
190
190
docker_setup_db () {
191
- if [ " $POSTGRES_DB " != ' postgres' ]; then
191
+ local dbAlreadyExists
192
+ dbAlreadyExists=" $( POSTGRES_DB= docker_process_sql --dbname postgres --set db=" $POSTGRES_DB " --tuples-only --command ' SELECT 1 FROM pg_database WHERE datname = :"db"' ) "
193
+ if [ -z " $dbAlreadyExists " ]; then
192
194
POSTGRES_DB= docker_process_sql --dbname postgres --set db=" $POSTGRES_DB " << -'EOSQL '
193
195
CREATE DATABASE :"db" ;
194
196
EOSQL
Original file line number Diff line number Diff line change @@ -188,7 +188,9 @@ docker_process_sql() {
188
188
# create initial database
189
189
# uses environment variables for input: POSTGRES_DB
190
190
docker_setup_db () {
191
- if [ " $POSTGRES_DB " != ' postgres' ]; then
191
+ local dbAlreadyExists
192
+ dbAlreadyExists=" $( POSTGRES_DB= docker_process_sql --dbname postgres --set db=" $POSTGRES_DB " --tuples-only --command ' SELECT 1 FROM pg_database WHERE datname = :"db"' ) "
193
+ if [ -z " $dbAlreadyExists " ]; then
192
194
POSTGRES_DB= docker_process_sql --dbname postgres --set db=" $POSTGRES_DB " << -'EOSQL '
193
195
CREATE DATABASE :"db" ;
194
196
EOSQL
Original file line number Diff line number Diff line change @@ -188,7 +188,9 @@ docker_process_sql() {
188
188
# create initial database
189
189
# uses environment variables for input: POSTGRES_DB
190
190
docker_setup_db () {
191
- if [ " $POSTGRES_DB " != ' postgres' ]; then
191
+ local dbAlreadyExists
192
+ dbAlreadyExists=" $( POSTGRES_DB= docker_process_sql --dbname postgres --set db=" $POSTGRES_DB " --tuples-only --command ' SELECT 1 FROM pg_database WHERE datname = :"db"' ) "
193
+ if [ -z " $dbAlreadyExists " ]; then
192
194
POSTGRES_DB= docker_process_sql --dbname postgres --set db=" $POSTGRES_DB " << -'EOSQL '
193
195
CREATE DATABASE :"db" ;
194
196
EOSQL
Original file line number Diff line number Diff line change @@ -188,7 +188,9 @@ docker_process_sql() {
188
188
# create initial database
189
189
# uses environment variables for input: POSTGRES_DB
190
190
docker_setup_db () {
191
- if [ " $POSTGRES_DB " != ' postgres' ]; then
191
+ local dbAlreadyExists
192
+ dbAlreadyExists=" $( POSTGRES_DB= docker_process_sql --dbname postgres --set db=" $POSTGRES_DB " --tuples-only --command ' SELECT 1 FROM pg_database WHERE datname = :"db"' ) "
193
+ if [ -z " $dbAlreadyExists " ]; then
192
194
POSTGRES_DB= docker_process_sql --dbname postgres --set db=" $POSTGRES_DB " << -'EOSQL '
193
195
CREATE DATABASE :"db" ;
194
196
EOSQL
You can’t perform that action at this time.
0 commit comments