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\"}"}
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?