© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•7mo ago
DanielBank

Unable to generate types with Supabase CLI due to permission denied for private schema

I get the error regardless of whether I have a private schema or not. My original intention was to update the db_pre_request function:

Migration:
create or REPLACE FUNCTION private.db_pre_request () returns void language plpgsql stable security definer
set search_path = public as $function$
declare groups jsonb;

begin -- get current groups from auth.users
select raw_app_meta_data->'groups'
from auth.users into groups
where id = auth.uid();

-- store it in the request object
perform set_config(
    'request.groups'::text,
    groups::text,
    false
    /* applies to transaction if true, session if false */
);

end;

$function$;

grant usage on schema private to authenticated,
    postgres;
create or REPLACE FUNCTION private.db_pre_request () returns void language plpgsql stable security definer
set search_path = public as $function$
declare groups jsonb;

begin -- get current groups from auth.users
select raw_app_meta_data->'groups'
from auth.users into groups
where id = auth.uid();

-- store it in the request object
perform set_config(
    'request.groups'::text,
    groups::text,
    false
    /* applies to transaction if true, session if false */
);

end;

$function$;

grant usage on schema private to authenticated,
    postgres;


Error generating types
> dotenv -e .env.local -- pnpm dlx supabase gen types --lang=typescript --project-id "$SUPABASE_PROJECT_ID" --schema public > src/types/database.ts

failed to retrieve generated types: {"message":"{\"code\":\"42501\",\"details\":null,\"hint\":null,\"message\":\"permission denied for schema private\"}"}
> dotenv -e .env.local -- pnpm dlx supabase gen types --lang=typescript --project-id "$SUPABASE_PROJECT_ID" --schema public > src/types/database.ts

failed to retrieve generated types: {"message":"{\"code\":\"42501\",\"details\":null,\"hint\":null,\"message\":\"permission denied for schema private\"}"}
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

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Permission denied for schema citext
SupabaseSSupabase / help-and-questions
13mo ago
Supabase Webhook causes ‘permission denied for schema net’ error
SupabaseSSupabase / help-and-questions
3mo ago
Permission denied on schema <schema_name> from supabase UI
SupabaseSSupabase / help-and-questions
3y ago
Permission denied on db push for schema private on GitHub Action
SupabaseSSupabase / help-and-questions
4y ago