https://supabase.com/ logo
#sql
Title
# sql
d

DyingAlbatross

08/01/2021, 6:21 PM
Anyone know if it's possible to create a procedure that's only callable with the service role?
s

silentworks

08/01/2021, 7:50 PM
You should be able to, but I haven’t tested this personally as yet. When I get back at my computer I will check.
d

DyingAlbatross

08/01/2021, 8:12 PM
Awesome, thank you!
k

Kosh

08/01/2021, 8:35 PM
You can do that using schemas, just check what auth.users table is actually under and use that schema too for your function. Something like Create or replace function myschema.my_function_name()
d

DyingAlbatross

08/01/2021, 8:35 PM
ahh, nice! great idea
It uses auth schema.
s

silentworks

08/01/2021, 8:40 PM
Be careful of adding tables and functions
k

Kosh

08/01/2021, 8:41 PM
Definitely, but its completely fine if using service role token which is what its meant for :)
s

silentworks

08/01/2021, 8:42 PM
These are schemas created by the Supabase team and could be modified in the future for upgrade purposes
k

Kosh

08/01/2021, 8:42 PM
How would you recommend that then? Creating new schema and grant it superuser?
s

silentworks

08/01/2021, 8:43 PM
Yes, but do note that the role of super user is being recommended against in the latest Postgres if I remember correctly