Repository navigation
fix(db): add the missing cloro_pending_tasks migration - #692
Merged
Merged
Conversation
The table was only ever applied to the hosted database and never committed here, so a fresh self-host install created every other table and then failed on this one with PGRST205, taking the Cloro webhook flow down with it — the callback could not resolve pending tasks, so scraper results were never stored. DDL is transcribed from the live database (columns, both foreign keys, both indexes, RLS enabled with no policies since only the service role touches it) and guarded with IF NOT EXISTS so existing deployments apply it as a no-op. Regenerated schema.sql and added the table to the web types, which were missing it too. Closes #652
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
cloro_pending_tasksis written and read by four server modules (server.js,job-manager.js,pulse/engine.js,tracking-worker.js) but had no DDL anywhere in the repo — not insupabase/migrations/, not inschema.sql, not in the web types. It only ever existed because it was applied directly to the hosted database.The consequence is that fresh self-host installs are broken: every other table is created, this one is not, and the server logs
The startup error is swallowed, so the failure surfaces later and more confusingly —
/cloro/callbackcannot resolve pending tasks, so scraper results are never stored and tracking silently produces nothing.What's in here
supabase/migrations/00049_cloro_pending_tasks.sql— transcribed from the live database: both foreign keys (prompt_id,brand_id, eachON DELETE CASCADE), both indexes (brand_idfor the drain loop's per-brand poll,submitted_atfor the stale sweep and the ghost-task exit added in Tracking cycle: stop waiting on ghost Cloro tasks — cuts the nightly cycle from ~5h to ~1.5h #687), and RLS enabled with no policies — only the service role touches this table and it bypasses RLS, so anything arriving with an anon/authenticated key correctly gets nothing.supabase/schema.sql.web/src/types/supabase.ts, which was also missing it.Every statement is guarded with
IF NOT EXISTS, so deployments that already have the table apply this as a no-op.Related issue
Closes #652 — reported by @Adarshhic
Type of change
fix— Bug fixHow to test
Fresh install (the path this fixes):
No
PGRST205on startup, and a Cloro callback resolves its pending task instead of failing to find the row.Existing database: applying the migration changes nothing — it is entirely
IF NOT EXISTS.Verification done
rowsecurity = trueare unchanged, and the row that was pending at the time survived untouched. This keeps the migration history aligned with the repo rather than leaving the file unrecorded.bash supabase/build-schema.shis deterministic against the committedschema.sql— re-running it produces no diff, so the CI schema check passes.yarn typecheckclean inweb/.Checklist
feature/,fix/,chore/,docs/)yarn lintpasses — no source files touchedyarn typecheckpassesyarn format:checkpasses —src/types/supabase.tsis Prettier-ignored as generated