这里可以看到报的错误是must be owner of table event,这个是个权限问题,说明在supabase跑SQL语句的时候的创建的表格所有者(owner)并不是此时部署时候需要的所有者(owner):postgres
顺着这个解决思路找到了一段可以修改数据库中表格所有者(owner)的一段SQL如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
DO$$DECLARErrecord;DECLAREv_schemavarchar:='public';v_new_ownervarchar:='postgres';BEGINFORrINselect'ALTER TABLE "'||table_schema||'"."'||table_name||'" OWNER TO '||v_new_owner||';'asafrominformation_schema.tableswheretable_schema=v_schemaunionallselect'ALTER TABLE "'||sequence_schema||'"."'||sequence_name||'" OWNER TO '||v_new_owner||';'asafrominformation_schema.sequenceswheresequence_schema=v_schemaunionallselect'ALTER TABLE "'||table_schema||'"."'||table_name||'" OWNER TO '||v_new_owner||';'asafrominformation_schema.viewswheretable_schema=v_schemaunionallselect'ALTER FUNCTION "'||nsp.nspname||'"."'||p.proname||'"('||pg_get_function_identity_arguments(p.oid)||') OWNER TO '||v_new_owner||';'asafrompg_procpjoinpg_namespacenspONp.pronamespace=nsp.oidwherensp.nspname=v_schemaLOOPEXECUTEr.a;ENDLOOP;END$$;