Skip to content

Commit c3da53d

Browse files
fix: DB migration script (#2779)
* use different approach to wait for postgres server
1 parent 891ff7d commit c3da53d

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

install/set-up-and-migrate-database.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,15 @@ echo "${_group}Setting up / migrating database ..."
22

33
# Fixes https://github.com/getsentry/self-hosted/issues/2758, where a migration fails due to indexing issue
44
$dc up -d postgres
5-
timeout 90s bash -c "until $dc exec postgres pg_isready ; do sleep 5 ; done"
5+
# Wait for postgres
6+
RETRIES=5
7+
until $dc exec postgres psql -U postgres -c "select 1" >/dev/null 2>&1 || [ $RETRIES -eq 0 ]; do
8+
echo "Waiting for postgres server, $((RETRIES--)) remaining attempts..."
9+
sleep 1
10+
done
611
indexes=$($dc exec postgres psql -qAt -U postgres -c "SELECT indexname, indexdef FROM pg_indexes WHERE tablename = 'sentry_groupedmessage';")
712
if [[ $indexes == *"sentry_groupedmessage_project_id_id_515aaa7e_uniq"* ]]; then
8-
$dc postgres psql -qAt -U postgres -c "DROP INDEX sentry_groupedmessage_project_id_id_515aaa7e_uniq;"
13+
$dc exec postgres psql -qAt -U postgres -c "DROP INDEX sentry_groupedmessage_project_id_id_515aaa7e_uniq;"
914
fi
1015

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

0 commit comments

Comments
 (0)