Skip to content

Commit

Permalink
Ensure postgres user has the replication privilege (#1456)
Browse files Browse the repository at this point in the history
  • Loading branch information
gunndabad authored Aug 8, 2024
1 parent 1214243 commit a10821a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion TeachingRecordSystem/db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ ENV_VARS=$(env | grep DefaultConnection | sed 's/^ConnectionStrings__DefaultConn
/^Password/ { print "export PGPASSWORD=" substr($0, 10) }
')
eval "$ENV_VARS"
psql
psql "$@"
11 changes: 8 additions & 3 deletions terraform/aks/app.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,18 @@ resource "kubernetes_job" "migrations" {
container {
name = "cli"
image = var.docker_image
command = ["trscli"]
args = ["migrate-db", "--connection-string", "$(CONNECTION_STRING)"]
command = ["/bin/ash", "-c"]
args = ["./db.sh -c 'alter user $(PG_USER) with replication;'", "trscli migrate-db --connection-string $(ConnectionStrings__DefaultConnection)"]

env {
name = "CONNECTION_STRING"
name = "ConnectionStrings__DefaultConnection"
value = module.postgres.dotnet_connection_string
}

env {
name = "PG_USER"
value = module.postgres.username
}
}

restart_policy = "Never"
Expand Down

0 comments on commit a10821a

Please sign in to comment.