Getting a permission denied error when trying to set parameter 'pgrst.db_pre_request'
In our NextJS/supabase project I'm trying to configure postgREST with a
db_pre_request
function according to the documentation https://postgrest.org/en/stable/configuration.html#db-pre-request and also following this github issue https://github.com/supabase/supabase/issues/3233
It works fine when I spin up my environment locally using supabase start
and supabase db reset
. The parameter gets set and my function runs correctly.
Unfortunately I get an error when I try to run the migrations for a linked supabase project. Here is the SQL in the migration that is failing
Here is the command and error I'm seeing
Can anyone help? My first thought is that whatever role is being used to run the migrations doesn't have the right GRANTs, but I don't know how to check that. Any other ideas, or solutions?GitHub
Expose PostgREST's
pre-request
config option to enable revoking l...Feature request Expose PostgREST's pre-request config option to enable revoking long-lived tokens Is your feature request related to a problem? Please describe. This issue is based on this ...
3 Replies
You may need to run as
supabase_admin
and not postgres
(aka, paste this into query tab in Studio instead of migrations)Thanks for the suggestion. I ended up running
alter role postgres superuser;
which fixed the issue. I ran the migrations, and then alter role postgres nosuperuser;
to put it back. This github issue was helpful.
https://github.com/supabase/cli/issues/96#issuecomment-1015083871
thanks @NanoBit for pointing in the right direction.Np. Be careful of running this and forgetting to set it back!