Skip to content

Commit

Permalink
chore: Make the script and guide more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
k3yss committed Aug 30, 2024
1 parent 15b0e7a commit c3035f9
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
4 changes: 1 addition & 3 deletions docs/pg-migration-guide/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,9 @@ Get the promoted instance PG15 connection string by running
$ tofu output --raw source_instance > pg_connection.txt
```


```sh
#TODO | Need to do a dry run again
$ ./postgres-perms-update.sh <db-name-whose-perms-we-want-to-be-fixed>
$ ./postgres-perms-update.sh <main.tf directory> <db-name-whose-perms-we-want-to-be-fixed>
```

# Step 4: Promote the instance
Expand Down Expand Up @@ -266,7 +265,6 @@ $ gcloud database-migration migration-jobs delete "test-job" --region=us-east1
```sh
$ gcloud sql instances list
# you might also need to disable the deletion protection
$ gcloud sql instances patch <source-instance-id> --no-deletion-protection
$ gcloud sql instances delete <source-instance-id>
$ gcloud sql instances delete <external-replica-instance-id>
```
Expand Down
2 changes: 1 addition & 1 deletion modules/postgresql/gcp/bin/create-dms.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
set -ex
set -e

# the directory we want to run the script in
dir=${1}
Expand Down
10 changes: 8 additions & 2 deletions modules/postgresql/gcp/bin/postgres-perms-update.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
#!/usr/bin/env bash
set -ex
set -e

dir=${1}
DB_NAME=${2}

pushd ${dir}

DB_NAME=${1}
NEW_OWNER=${DB_NAME}-user
# READ PG_CON from a file
PG_CON=$(cat pg_connection.txt)
Expand Down Expand Up @@ -29,3 +33,5 @@ for sequence in $sequences; do
done

echo "Ownership of all tables in $DB_NAME has been granted to $NEW_OWNER."

popd
2 changes: 1 addition & 1 deletion modules/postgresql/gcp/bin/terraform-db-swap.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
set -ex
set -e

dir=${1}
module_prefix=${2}
Expand Down
2 changes: 1 addition & 1 deletion modules/postgresql/gcp/bin/terraform-state-rm.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
set -ex
set -e

dir=${1}
module_prefix=${2}
Expand Down

0 comments on commit c3035f9

Please sign in to comment.