fix(repo): pg-upgrade counts tables with a query PostgreSQL accepts (#1245) #1333

Merged
claude-bot merged 3 commits from fix/1245-pg-upgrade-count into main 2026-11-04 19:17:26 +00:00
Collaborator

Found by the 4.7.0-rc1 rehearsal on dev (#1245), which is what the rehearsal is for.

What happened. make pg-upgrade stopped at step 4 with ERROR: collations are not supported by type integer. The count query ended order by 1 collate "C", and PostgreSQL reads 1 there as the integer literal, not as "the first column". The script failed safe as designed: the new volume was removed, the old volume was untouched, and the app was left stopped. Dev was back on 4.6.2 within about two minutes, with every service healthy and no data changed.

The fix. Order by table_name::text collate "C". Checked read-only against dev's live PostgreSQL 16 (115 tables counted) and against a throwaway PostgreSQL 18.

Why nothing caught it. The script's tests check the guard, the volumes and sh -n, but none ran the query on a database. A new test now pulls COUNT_SQL out of the script and runs it on the suite's own PostgreSQL. It passes with the fix (13 passed) and fails with the old query, with the same error dev saw. ruff is clean.

Next: merge, cut v4.7.0-rc2 (rc1's tag contains the broken script), and run the dev rehearsal again.

🤖 Generated with Claude Code

Found by the 4.7.0-rc1 rehearsal on dev (#1245), which is what the rehearsal is for. **What happened.** `make pg-upgrade` stopped at step 4 with `ERROR: collations are not supported by type integer`. The count query ended `order by 1 collate "C"`, and PostgreSQL reads `1` there as the integer literal, not as "the first column". The script failed safe as designed: the new volume was removed, the old volume was untouched, and the app was left stopped. **Dev was back on 4.6.2 within about two minutes, with every service healthy and no data changed.** **The fix.** Order by `table_name::text collate "C"`. Checked read-only against dev's live PostgreSQL 16 (115 tables counted) and against a throwaway PostgreSQL 18. **Why nothing caught it.** The script's tests check the guard, the volumes and `sh -n`, but none ran the query on a database. A new test now pulls `COUNT_SQL` out of the script and runs it on the suite's own PostgreSQL. It passes with the fix (13 passed) and fails with the old query, with the same error dev saw. ruff is clean. **Next:** merge, cut `v4.7.0-rc2` (rc1's tag contains the broken script), and run the dev rehearsal again. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The 4.7.0-rc1 rehearsal on dev stopped at step 4: 'order by 1 collate
"C"' reads 1 as an integer literal, which takes no collation, so the
old cluster's tables could not be counted. It failed safe (the new
volume was removed, the old one untouched) and dev went back to 4.6.2.
The query now orders by table_name::text collate "C", and a test runs
it on the suite's own PostgreSQL, which nothing did before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
style: ruff format the pg-upgrade test (#1245)
Some checks failed
CI / Does this change touch the recording path? (pull_request) Successful in 26s
CI / Synthetic session harness (no GPU, no LLM) (pull_request) Has been skipped
CI / Which journeys does this change need? (pull_request) Successful in 21s
CI / Bot/backend version sync (pull_request) Successful in 49s
CI / Summarisation accuracy eval harness (stub provider) (pull_request) Successful in 1m1s
CI / Backend lint (ruff) (pull_request) Successful in 57s
CI / Feedback site tests (pull_request) Successful in 1m36s
CI / Bot tests and audit (pull_request) Successful in 2m13s
CI / Docker image build (pull_request) Failing after 4m14s
CI / End-to-end journeys (desktop) (pull_request) Has been skipped
CI / Frontend (shard 2/2) (pull_request) Successful in 9m17s
CI / Frontend (shard 1/2) (pull_request) Successful in 10m33s
CI / Backend migration, tests, and audit (pull_request) Successful in 36m39s
b9e682393d
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude-bot scheduled this pull request to auto merge when all checks succeed 2026-11-04 18:40:22 +00:00
ci: rerun after a network drop fetching the PGDG key (#1245)
All checks were successful
CI / Backend lint (ruff) (pull_request) Successful in 33s
CI / Which journeys does this change need? (pull_request) Successful in 25s
CI / Does this change touch the recording path? (pull_request) Successful in 26s
CI / Synthetic session harness (no GPU, no LLM) (pull_request) Has been skipped
CI / Bot/backend version sync (pull_request) Successful in 39s
CI / Summarisation accuracy eval harness (stub provider) (pull_request) Successful in 1m13s
CI / Feedback site tests (pull_request) Successful in 1m17s
CI / Bot tests and audit (pull_request) Successful in 2m11s
CI / Docker image build (pull_request) Successful in 5m44s
CI / Frontend (shard 2/2) (pull_request) Successful in 9m43s
CI / Frontend (shard 1/2) (pull_request) Successful in 11m0s
CI / End-to-end journeys (desktop) (pull_request) Successful in 13m55s
CI / Backend migration, tests, and audit (pull_request) Successful in 36m55s
4ad15ec59a
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
rbrooks referenced this pull request from a commit 2026-11-04 19:18:37 +00:00
Sign in to join this conversation.
No description provided.