JS如何通过调用边缘函数来创建表?
这是我写的边缘函数:https://github.com/zhangpanonline/enterprise-admin/blob/dev/src/edgeFunction/create_table.ts。
然后我通过 POST https://smmexdymolziqxyrvctw.supabase.co/functions/v1/create_table 接口,入参{"name":"sys_demo"},接口返回permission denied for schema public。
如何解决这个错误?
2 Replies
You seem to be calling a function that runs SQL directly from the REST API. That is not a good idea in general.
Your issue is likely that service_role does not have the ability to create tables. It can only use the public schema.
You don't show your rpc function so hard to know what it is doing. Likely it would need to be security definer type to create tables.
But then you have to protect it as if you mess that up, anyone can run SQL on your database.
Please ask your questions in English as the rule 3 states in the rules of this platform https://discord.com/channels/839993398554656828/843998099033817088/854280602073169942