fix(db): guard chat_connections copy on table existence#525
Merged
Conversation
The drop-chat_connections migration assumed the source table was always present, but on prod the table was never materialized (or already gone), so the INSERT...FROM public.chat_connections raised "relation does not exist" and the pre-upgrade hook failed BackoffLimitExceeded — Flux then stalled the HelmRelease after 3 retries. Wrap the data-copy in a DO block guarded by to_regclass so the migration is a no-op when chat_connections is absent. The trailing DROP TABLE IF EXISTS already handles both cases.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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
20260502000000_drop_chat_connections.sqlwas failing the pre-upgrade Helm hook onsummaries-prod(HelmRelease/summaries-appstalled,BackoffLimitExceededonsummaries-app-owletto-migrate).INSERT INTO agent_connections ... FROM public.chat_connectionsunconditionally. Prod's DB never hadchat_connections(the originatingIF NOT EXISTStable from refactor: unify connection storage on agent_connections, drop chat_connections #506-era migration was no-op'd or already cleaned up), so Postgres errored withrelation "public.chat_connections" does not existbefore reachingDROP TABLE IF EXISTS.DOblock guarded byto_regclass('public.chat_connections') IS NOT NULL. Idempotent on both fresh deployments (no source table) and live deployments (rows copied as before).Test plan
BEGIN...ROLLBACK— completed without error.summaries-app-owletto-migrate→ HelmRelease goes Ready.chat_connectionsrows that the copy still occurs (not currently in any environment, but logic preserved).