Switch PG to wxyc-postgres image; add F0000 precheck on 0003#45
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
postgres:16-alpinetoghcr.io/wxyc/wxyc-postgres:pg16indocker-compose.ymland CI; drop thedocker cp wxyc_unaccent.rulesstaging step.CREATE TEXT SEARCH DICTIONARY wxyc_unaccentinmigrations/0003_wxyc_identity_match_functions.sqlwith anEXCEPTION WHEN SQLSTATE 'F0000'block that re-raises with the operator runbook URL when the rules file is missing.#[ignore]-gated live-PG test that pins the F0000 SQLSTATE contract via a deliberately-missing rules-file probe.Test plan
cargo fmt --checkcargo clippy --all-targets -- -D warningscargo test --test wxyc_identity_match_parity_test(4 passing static gates incl. the 2 new ones)ghcr.io/wxyc/wxyc-postgres:pg16(one-time, tracked in the wxyc-postgres runbook)workflow_dispatchofrebuild-cache.ymlafter the Railway swapCloses #41