Skip to content

Commit

Permalink
fix: DB migration script (#2779)
Browse files Browse the repository at this point in the history
* use different approach to wait for postgres server
  • Loading branch information
hubertdeng123 committed Feb 9, 2024
1 parent 891ff7d commit c3da53d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions install/set-up-and-migrate-database.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@ echo "${_group}Setting up / migrating database ..."

# Fixes https://github.com/getsentry/self-hosted/issues/2758, where a migration fails due to indexing issue
$dc up -d postgres
timeout 90s bash -c "until $dc exec postgres pg_isready ; do sleep 5 ; done"
# Wait for postgres
RETRIES=5
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
indexes=$($dc exec postgres psql -qAt -U postgres -c "SELECT indexname, indexdef FROM pg_indexes WHERE tablename = 'sentry_groupedmessage';")
if [[ $indexes == *"sentry_groupedmessage_project_id_id_515aaa7e_uniq"* ]]; then
$dc postgres psql -qAt -U postgres -c "DROP INDEX sentry_groupedmessage_project_id_id_515aaa7e_uniq;"
$dc exec postgres psql -qAt -U postgres -c "DROP INDEX sentry_groupedmessage_project_id_id_515aaa7e_uniq;"
fi

if [[ -n "${CI:-}" || "${SKIP_USER_CREATION:-0}" == 1 ]]; then
Expand Down

0 comments on commit c3da53d

Please sign in to comment.