@@ -19,8 +19,8 @@ echo "☁️ Enabling the Cloud SQL API..."
19
19
gcloud config set project ${PROJECT_ID}
20
20
gcloud services enable sqladmin.googleapis.com
21
21
22
- CSQL_EXISTS=$( gcloud sql instances list --filter=" ${INSTANCE_NAME} " )
23
- if [ $CSQL_EXISTS = " Listed 0 items. " ]; then
22
+ CSQL_EXISTS=$( gcloud sql instances list --filter=" ${INSTANCE_NAME} " | wc -l )
23
+ if [ $CSQL_EXISTS = " 0 " ]; then
24
24
echo " ☁️ Creating Cloud SQL instance: ${INSTANCE_NAME} ..."
25
25
gcloud sql instances create $INSTANCE_NAME \
26
26
--database-version=POSTGRES_12 --tier=db-custom-1-3840 \
@@ -35,15 +35,15 @@ gcloud sql users create admin \
35
35
--instance=$INSTANCE_NAME --password=admin
36
36
37
37
# Create Accounts DB
38
- ACCOUNTS_DB_EXISTS=$( gcloud sql databases list --instance=${INSTANCE_NAME} --filter=" accounts-db" )
39
- if [ $ACCOUNTS_DB_EXISTS = " Listed 0 items. " ]; then
38
+ ACCOUNTS_DB_EXISTS=$( gcloud sql databases list --instance=${INSTANCE_NAME} --filter=" accounts-db" | wc -l )
39
+ if [ $ACCOUNTS_DB_EXISTS = " 0 " ]; then
40
40
echo " ☁️ Creating accounts-db in ${INSTANCE_NAME} ..."
41
41
gcloud sql databases create accounts-db --instance=$INSTANCE_NAME
42
42
fi
43
43
44
44
# Create Ledger DB
45
- LEDGER_DB_EXISTS=$( gcloud sql databases list --instance=${INSTANCE_NAME} --filter=" ledger-db" )
46
- if [ $LEDGER_DB_EXISTS = " Listed 0 items. " ]; then
45
+ LEDGER_DB_EXISTS=$( gcloud sql databases list --instance=${INSTANCE_NAME} --filter=" ledger-db" | wc -l )
46
+ if [ $LEDGER_DB_EXISTS = " 0 " ]; then
47
47
echo " ☁️ Creating ledger-db in ${INSTANCE_NAME} ..."
48
48
gcloud sql databases create ledger-db --instance=$INSTANCE_NAME
49
49
fi
0 commit comments