Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use docker compose exec to account for differences in container names for Postgres upgrade #2096

Merged
merged 3 commits into from
Apr 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions install/upgrade-postgres.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,18 @@ if [[ -n "$(docker volume ls -q --filter name=sentry-postgres)" && "$(docker run

# Wait for postgres
RETRIES=5
until docker exec sentry-self-hosted-postgres-1 psql -U postgres -c "select 1" >/dev/null 2>&1 || [ $RETRIES -eq 0 ]; do
until $dc exec postgres psql -U postgres -c "select 1" >/dev/null 2>&1 || [ $RETRIES -eq 0 ]; do
echo "Waiting for postgres server, $((RETRIES--)) remaining attempts..."
sleep 1
done

# VOLUME_NAME is the same as container name
# Reindex all databases and their system catalogs which are not templates
DBS=$(docker exec sentry-self-hosted-postgres-1 psql -qAt -U postgres -c "SELECT datname FROM pg_database WHERE datistemplate = false;")
DBS=$($dc exec postgres psql -qAt -U postgres -c "SELECT datname FROM pg_database WHERE datistemplate = false;")
for db in ${DBS}; do
echo "Re-indexing database: ${db}"
docker exec sentry-self-hosted-postgres-1 psql -qAt -U postgres -d ${db} -c "reindex system ${db}"
docker exec sentry-self-hosted-postgres-1 psql -qAt -U postgres -d ${db} -c "reindex database ${db};"
$dc exec postgres psql -qAt -U postgres -d ${db} -c "reindex system ${db}"
$dc exec postgres psql -qAt -U postgres -d ${db} -c "reindex database ${db};"
done

$dc stop postgres
Expand Down