You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: ansible/files/admin_api_scripts/pg_upgrade_scripts/complete.sh
+30-1Lines changed: 30 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -24,6 +24,32 @@ function cleanup {
24
24
exit"$EXIT_CODE"
25
25
}
26
26
27
+
functionexecute_patches {
28
+
# Patch pg_net grants
29
+
PG_NET_ENABLED=$(run_sql -A -t -c "select count(*) > 0 from pg_extension where extname = 'pg_net';")
30
+
31
+
if [ "$PG_NET_ENABLED"="t" ];then
32
+
PG_NET_GRANT_QUERY=$(cat <<EOF
33
+
GRANT USAGE ON SCHEMA net TO supabase_functions_admin, postgres, anon, authenticated, service_role;
34
+
35
+
ALTER function net.http_get(url text, params jsonb, headers jsonb, timeout_milliseconds integer) SECURITY DEFINER;
36
+
ALTER function net.http_post(url text, body jsonb, params jsonb, headers jsonb, timeout_milliseconds integer) SECURITY DEFINER;
37
+
38
+
ALTER function net.http_get(url text, params jsonb, headers jsonb, timeout_milliseconds integer) SET search_path = net;
39
+
ALTER function net.http_post(url text, body jsonb, params jsonb, headers jsonb, timeout_milliseconds integer) SET search_path = net;
40
+
41
+
REVOKE ALL ON FUNCTION net.http_get(url text, params jsonb, headers jsonb, timeout_milliseconds integer) FROM PUBLIC;
42
+
REVOKE ALL ON FUNCTION net.http_post(url text, body jsonb, params jsonb, headers jsonb, timeout_milliseconds integer) FROM PUBLIC;
43
+
44
+
GRANT EXECUTE ON FUNCTION net.http_get(url text, params jsonb, headers jsonb, timeout_milliseconds integer) TO supabase_functions_admin, postgres, anon, authenticated, service_role;
45
+
GRANT EXECUTE ON FUNCTION net.http_post(url text, body jsonb, params jsonb, headers jsonb, timeout_milliseconds integer) TO supabase_functions_admin, postgres, anon, authenticated, service_role;
46
+
EOF
47
+
)
48
+
49
+
run_sql -c "$PG_NET_GRANT_QUERY"
50
+
fi
51
+
}
52
+
27
53
functioncomplete_pg_upgrade {
28
54
if [ -f /tmp/pg-upgrade-status ];then
29
55
echo"Upgrade job already started. Bailing."
@@ -45,9 +71,12 @@ function complete_pg_upgrade {
45
71
echo"4. Running generated SQL files"
46
72
retry 3 run_generated_sql
47
73
74
+
echo"4.1. Applying patches"
75
+
execute_patches ||true
76
+
48
77
run_sql -c "ALTER USER postgres WITH NOSUPERUSER;"
0 commit comments