Β© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabaseβ€’5mo agoβ€’
3 replies
tommyconfetti

Persistent Schema Cache Error: "Could not find a relationship" despite correct Foreign Key

Hi everyone! Our team is working on a simple Next.js blog app for a practice exercise. The goal is for an admin to log in and create posts that everyone can see. We've hit a wall with a persistent schema cache error and would really appreciate some help.

When our homepage tries to fetch all posts, the API fails with: Could not find a relationship between 'posts' and 'users' in the schema cache.

Environment:

- Framework: Next.js v15.5.4

- Platform: Web

- Libraries: @supabase/supabase-js@2.58.0, @supabase/auth-helpers-nextjs@0.10.0

Failing API Code (/api/posts/index.js):

import { supabase } from "../../../lib/supabaseClient";

export default async function getAllPost(req, res) {
try {
const { data, error } = await supabase.from('posts').select('*, users(email)');
if (error) { throw error; }
res.status(200).json(data);
} catch (error) {
res.status(500).json({ error: error.message });
}
}

What We've Tried:
We've confirmed our schema is correct: posts.author_id is a uuid with a Foreign Key pointing directly to auth.users.id. We've already tried all the standard fixes we could find:

- Running NOTIFY pgrst, 'reload schema';

- A full project pause and restart.

- Manually recreating the foreign key with ALTER TABLE.

The error still persists, which makes us think the schema cache is stuck. Since this is just for a team practice project, we're really hoping to get past this blocker. Any advice on how to force a hard reset would be amazing. Thank you!
Screenshot_2025-10-04_012542.png
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Could not find a relationship in the schema cache
SupabaseSSupabase / help-and-questions
13mo ago
Could not find a relationship between 'messages' and 'user' in the schema cache
SupabaseSSupabase / help-and-questions
14mo ago
Could not find a relationship between 'ev_opportunities' and 'sportsbooks' in the schema cache
SupabaseSSupabase / help-and-questions
3mo ago
inner join without foreign key relationship
SupabaseSSupabase / help-and-questions
3y ago