From fd24a3a5483cdd8aa588c2bab598554ee07f8e7c Mon Sep 17 00:00:00 2001 From: nessi Date: Fri, 13 Feb 2026 08:27:52 +0100 Subject: [PATCH] Enable `pg_stat_statements` in PostgreSQL containers This change modifies the GitHub Actions workflow to enable the `pg_stat_statements` extension in PostgreSQL service containers during tests. It ensures the required settings are applied and the database is properly restarted to reflect the changes, improving compatibility checks and diagnostics. --- .github/workflows/pg-compat-matrix.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/.github/workflows/pg-compat-matrix.yml b/.github/workflows/pg-compat-matrix.yml index 55c4d14..ae28fa8 100644 --- a/.github/workflows/pg-compat-matrix.yml +++ b/.github/workflows/pg-compat-matrix.yml @@ -41,6 +41,28 @@ jobs: - name: Install backend dependencies run: pip install -r backend/requirements.txt + - name: Enable pg_stat_statements in service container + run: | + PG_CID="$(docker ps --filter "ancestor=postgres:${{ matrix.pg_version }}" --format "{{.ID}}" | head -n1)" + if [ -z "$PG_CID" ]; then + echo "Could not find postgres service container for version ${{ matrix.pg_version }}" + docker ps -a + exit 1 + fi + + echo "Using postgres container: $PG_CID" + docker exec "$PG_CID" psql -U postgres -d compatdb -c "ALTER SYSTEM SET shared_preload_libraries = 'pg_stat_statements';" + docker restart "$PG_CID" + + for i in $(seq 1 40); do + if docker exec "$PG_CID" pg_isready -U postgres -d compatdb; then + break + fi + sleep 2 + done + + docker exec "$PG_CID" psql -U postgres -d compatdb -c "CREATE EXTENSION IF NOT EXISTS pg_stat_statements;" + - name: Run PostgreSQL compatibility smoke checks env: PG_DSN_CANDIDATES: postgresql://postgres:postgres@postgres:5432/compatdb?sslmode=disable,postgresql://postgres:postgres@127.0.0.1:5432/compatdb?sslmode=disable