Skip to content

Switch PG to wxyc-postgres image; add F0000 precheck on 0003#45

Merged
jakebromberg merged 3 commits into
mainfrom
cross-cache-identity/wxyc-postgres-image
Jun 2, 2026
Merged

Switch PG to wxyc-postgres image; add F0000 precheck on 0003#45
jakebromberg merged 3 commits into
mainfrom
cross-cache-identity/wxyc-postgres-image

Conversation

@jakebromberg

Copy link
Copy Markdown
Member

Summary

  • Swap postgres:16-alpine to ghcr.io/wxyc/wxyc-postgres:pg16 in docker-compose.yml and CI; drop the docker cp wxyc_unaccent.rules staging step.
  • Wrap CREATE TEXT SEARCH DICTIONARY wxyc_unaccent in migrations/0003_wxyc_identity_match_functions.sql with an EXCEPTION WHEN SQLSTATE 'F0000' block that re-raises with the operator runbook URL when the rules file is missing.
  • Add static tests pinning the F0000 catch + runbook URL in the migration body, plus an #[ignore]-gated live-PG test that pins the F0000 SQLSTATE contract via a deliberately-missing rules-file probe.

Test plan

  • cargo fmt --check
  • cargo clippy --all-targets -- -D warnings
  • cargo test --test wxyc_identity_match_parity_test (4 passing static gates incl. the 2 new ones)
  • CI test-postgres job (wxyc-postgres image + parity tests + new F0000 probe) — runs on push
  • Operator follow-up: swap Railway PG service to ghcr.io/wxyc/wxyc-postgres:pg16 (one-time, tracked in the wxyc-postgres runbook)
  • workflow_dispatch of rebuild-cache.yml after the Railway swap

Closes #41

Migration 0003's `CREATE TEXT SEARCH DICTIONARY wxyc_unaccent (... RULES = 'wxyc_unaccent')` requires `wxyc_unaccent.rules` at `$SHAREDIR/tsearch_data/` on the destination Postgres. CI previously staged this via `docker cp` into a `postgres:16-alpine` service; Railway production had no provisioning step at all, so the next fresh-DB run of `rebuild-cache.yml` would have failed with `ConfigFileError`.

Local + CI now run `ghcr.io/wxyc/wxyc-postgres:pg16`, which bakes the rules file into the image. Migration 0003 wraps the `CREATE TEXT SEARCH DICTIONARY` call in a plpgsql block that catches SQLSTATE F0000 and re-raises with the operator runbook URL, so a stock-image deploy fails fast with an actionable message. Other SQLSTATEs propagate unchanged.

Tests pin the F0000 catch + runbook URL statically, and a new `#[ignore]`-gated integration test exercises the F0000 SQLSTATE via a deliberately-missing rules-file probe (independent of the migration body) so a future Postgres SQLSTATE change surfaces as a test failure rather than silently neutering the catch.

Operator follow-up: swap the Railway PG service to the same image (one-time, tracked in the wxyc-postgres runbook).

Closes #41
…SQLSTATE alias

Code-review pass. Five small follow-ups to the prior commit:

- Move `DROP TEXT SEARCH DICTIONARY IF EXISTS wxyc_unaccent` INSIDE the DO block so it rolls back with the EXCEPTION-arm savepoint on the F0000 path. A runner using autocommit per statement (e.g. postgres-crate `batch_execute`) would otherwise commit the DROP and destroy a previously-good dict before the failing CREATE.
- Broaden the wrapper message from "is missing" to "is missing or unreadable". F0000 also fires for present-but-corrupt rules files; the prior text directed operators at the wrong fix.
- Mention `:pg17` alongside `:pg16` in the message, matching the comment one line above. Operators on pg17 destinations were getting pg16-specific guidance.
- `migration_catches_f0000_sqlstate` now accepts either `WHEN SQLSTATE 'F0000'` or the named-condition alias `WHEN config_file_error`. Both are valid plpgsql; the test should not break a future cleanup that prefers the named form.
- `missing_rules_file_emits_f0000_sqlstate` drops `wxyc_nonexistent_probe` before creating it, so a stale probe dict left from a prior aborted run doesn't surface as 42710 duplicate_object on retry.
- Comment now correctly frames DROP-inside-DO as defense-in-depth (sqlx-cli + batch_execute already roll back atomically; the savepoint protects truly per-statement-autocommit runners).
- Error MESSAGE no longer asserts a specific failure cause ("missing", "unreadable") since F0000 also covers parse errors in the rules file; the original cause now surfaces via DETAIL = SQLERRM and the MESSAGE points operators at the runbook + image swap.
@jakebromberg jakebromberg merged commit a51b834 into main Jun 2, 2026
3 checks passed
@jakebromberg jakebromberg deleted the cross-cache-identity/wxyc-postgres-image branch June 2, 2026 23:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Switch PG to wxyc-postgres image; add F0000 precheck to migration 0003

1 participant