self-hosted/install/set-up-and-migrate-database.sh
Frederik Spang 2862432828
Add pgbouncer (#3884)
* Add patch for pgbouncer

* pgcat over pgbouncer

* Add patch for .env file

* Apply patches and add initial pgcat tolm file

* feat: hardcode pgcat image

* Fixes from review

* Align usernames defaults

* Remove postgres from default depends_on; Covered by pgcat by extension

* Set user and password - pgcat maybe doesnt support host auth trust

* Pool name maybe has to match, for some reason

* Use healthcheck from pgcat PR

* Reduce pool size, leave some for healthchecks and other clients running

* Start pgcat for bash scripts with postgres

* Update docker-compose.yml

* Use pgbouncer

* Revert to TRUST method
2025-08-23 20:18:13 +07:00

29 lines
945 B
Bash

echo "${_group}Setting up / migrating database ..."
if [[ -z "${SKIP_SENTRY_MIGRATIONS:-}" ]]; then
# Fixes https://github.com/getsentry/self-hosted/issues/2758, where a migration fails due to indexing issue
start_service_and_wait_ready postgres
start_service_and_wait_ready pgbouncer
os=$($dc exec postgres cat /etc/os-release | grep 'ID=debian')
if [[ -z $os ]]; then
echo "Postgres image debian check failed, exiting..."
exit 1
fi
if [[ -n "${CI:-}" || "${SKIP_USER_CREATION:-0}" == 1 ]]; then
$dcr web upgrade --noinput --create-kafka-topics
echo ""
echo "Did not prompt for user creation. Run the following command to create one"
echo "yourself (recommended):"
echo ""
echo " $dc_base run --rm web createuser"
echo ""
else
$dcr web upgrade --create-kafka-topics
fi
else
echo "Skipped DB migrations due to SKIP_SENTRY_MIGRATIONS=$SKIP_SENTRY_MIGRATIONS"
fi
echo "${_endgroup}"