Skip to content

bug: Missing cloro_pending_tasks migration breaks fresh installs #652

Closed

Description

@Adarshhic

Description

cloro_pending_tasks is referenced in multiple places (server.js, job-manager.js, pulse/engine.js, and tracking-worker.js), but there is no migration creating the table in supabase/migrations/ or supabase/schema.sql.

On a fresh self-hosted install (supabase db reset → npm run dev), the server logs:

PGRST205: Could not find the table 'public.cloro_pending_tasks' in the schema cache

Although the startup error is swallowed, it also breaks the Cloro webhook flow because /cloro/callback cannot resolve pending tasks from the missing table.

Suggested fix: Add a migration creating cloro_pending_tasks (matching the fields used by server.js/tracking-worker.js) and regenerate supabase/schema.sql.

Steps to reproduce

  1. Run supabase db reset.
  2. Start the server with cd server && npm run dev.
  3. Observe the PGRST205 error on startup.
  4. Trigger a Cloro webhook callback and notice it cannot resolve the pending task.

Expected behavior

A fresh installation should create cloro_pending_tasks during database setup, allowing the server to start without errors and Cloro webhook callbacks to resolve pending tasks successfully.

Actual behavior

cloro_pending_tasks is missing after running all migrations. The server logs PGRST205 on startup, and Cloro webhook callbacks fail because the pending task table does not exist.

Deployment mode

Self-hosted

Environment

Windows 11, Node.js (your version), Supabase CLI (your version)

Relevant logs

PGRST205: Could not find the table 'public.cloro_pending_tasks' in the schema cache

Activity

  1. added
    bug
    on Aug 7, 2026
  2. gkhngyk commented on Aug 7, 2026

    @gkhngyk
    Contributor

    Confirmed — good catch. The table exists on the hosted database but its DDL was never committed as a migration, so fresh installs never create it. Nothing to guess about the shape; here is the authoritative definition from the live database:

    CREATE TABLE IF NOT EXISTS public.cloro_pending_tasks (
      task_id text PRIMARY KEY,
      prompt_id uuid NOT NULL REFERENCES public.prompts(id) ON DELETE CASCADE,
      brand_id uuid NOT NULL REFERENCES public.brands(id) ON DELETE CASCADE,
      scraper_id text NOT NULL,
      region text,
      submitted_at timestamptz NOT NULL DEFAULT now()
    );
    
    CREATE INDEX IF NOT EXISTS idx_cloro_pending_tasks_brand_id ON public.cloro_pending_tasks(brand_id);
    CREATE INDEX IF NOT EXISTS idx_cloro_pending_tasks_submitted_at ON public.cloro_pending_tasks(submitted_at);
    
    ALTER TABLE public.cloro_pending_tasks ENABLE ROW LEVEL SECURITY;
    -- No policies on purpose: the table is only touched by the server through the
    -- service role (it's a transient submit-queue for the tracking worker).

    To fix:

    1. Add the DDL above as a new numbered file in supabase/migrations/ (use the next free number). Keep the IF NOT EXISTS guards — databases that already have the table must be able to run it as a no-op.
    2. Regenerate the consolidated schema with bash supabase/build-schema.sh (CI checks that supabase/schema.sql is in sync).
    3. Add the table to web/src/types/supabase.ts — it is missing there too.

    Open to anyone who wants to pick this up.

  3. added a commit that references this issue on Aug 10, 2026
    8d00fe6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions