Skip to content

fix(db): reload PostgREST schema cache so open_to_work_email is writable - #126

Merged
nikshepsvn merged 3 commits into
sculptdotfun:mainfrom
panbergco:fix/pgrst-schema-cache-reload
Aug 18, 2026
Merged

fix(db): reload PostgREST schema cache so open_to_work_email is writable#126
nikshepsvn merged 3 commits into
sculptdotfun:mainfrom
panbergco:fix/pgrst-schema-cache-reload

Conversation

@panbergco

Copy link
Copy Markdown
Contributor

Saving a contact email on /hire fails with:

Could not find the 'open_to_work_email' column of 'profiles' in the schema cache

Reproduced on production today (profile panbergco, tier Supernova, rank #7) while opting in to open-to-work.

Cause

The column is not missing. 009_open_to_work_email.sql adds it and setOpenToWork in src/lib/data/supabase/client.ts writes it. But PostgREST serves a cached copy of the schema, and no migration in supabase/migrations/ ever asks it to reload β€” grep -rn "NOTIFY\|pgrst" supabase/migrations/ returns nothing. So the API rejects the write with PGRST204 while the column exists in the table.

Supabase reloads the cache on its own eventually, and the dashboard SQL editor usually triggers it β€” which is why this does not reproduce in a fresh local setup. A migration applied via the supabase CLI or a direct psql connection does not trigger it.

Fix

Adds 013_reload_schema_cache.sql:

NOTIFY pgrst, 'reload schema';

Kept as its own migration rather than a line appended to 009, because the cache is global: one reload republishes every column from every earlier migration, so any other stale column is fixed at the same time. Safe to re-run and harmless when the cache is already current.

README gains a note to run it last, and again after any future migration that adds a column.

Notes

Saving a contact email on /hire fails with:

  Could not find the 'open_to_work_email' column of 'profiles'
  in the schema cache

The column is not missing. Migration 009 adds it and setOpenToWork writes
it, but PostgREST serves a cached schema and no migration ever asks it to
reload, so the API rejects the write (PGRST204) while the column exists in
the table.

Add 013_reload_schema_cache.sql issuing NOTIFY pgrst, 'reload schema'.
The cache is global, so one reload republishes every column from every
earlier migration rather than just this one. Safe to re-run.

Document it in the README so the reload is run after any future migration
that adds a column.
@vercel

vercel Bot commented Aug 8, 2026

Copy link
Copy Markdown

@panbergco is attempting to deploy a commit to the sculpt Team on Vercel.

A member of the Team first needs to authorize it.

nikshepsvn and others added 2 commits August 18, 2026 15:47
013 was taken by month_stats on main while this PR was open. The /hire
email failure was the column genuinely missing in prod (009 unapplied),
not a stale cache β€” but the explicit reload is right for any migration
applied over psql or the management API, so it stays as 014.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@nikshepsvn

Copy link
Copy Markdown
Contributor

Thanks for the report and the fix β€” merging with two adjustments:

  1. Renumbered 013 β†’ 014 (013 was taken by 013_month_stats.sql on main while this was open).
  2. Corrected the diagnosis in the migration comment: reproduced your error, and it was Postgres 42703 ("column does not exist"), not PGRST204 β€” migration 009 had never actually been applied to production. It's applied now, along with the schema reload, and saving a contact email on /hire works again. Your reload migration is still the right guardrail for any future migration applied over psql or the management API, so it stays.

πŸ€– Generated with Claude Code

@nikshepsvn
nikshepsvn merged commit 12a9f61 into sculptdotfun:main Aug 18, 2026
1 check failed
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.

2 participants