Skip to content

Commit b6273dd

Browse files
authored
Merge pull request #81 from supabase-community/upgrade-202311
chore: Upgrade 2023.11
2 parents 0234279 + fbeb58e commit b6273dd

16 files changed

+268
-109
lines changed

.projen/deps.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.projenrc.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ const project = new awscdk.AwsCdkTypeScriptApp({
1111
'@aws-cdk/aws-apigatewayv2-alpha',
1212
'@aws-cdk/aws-apigatewayv2-integrations-alpha',
1313
// Lambda Powertools
14-
'@aws-lambda-powertools/logger@1.14.2',
15-
'@aws-lambda-powertools/tracer@1.14.2',
14+
'@aws-lambda-powertools/logger@1.16.0',
15+
'@aws-lambda-powertools/tracer@1.16.0',
1616
// AWS SDK
1717
'@aws-sdk/client-cloudfront',
1818
'@aws-sdk/client-ecs',

package.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/supabase-cdn/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ class CacheManager extends Construct {
156156
],
157157
},
158158
layers: [
159-
lambda.LayerVersion.fromLayerVersionArn(this, 'LambdaPowertools', `arn:aws:lambda:${cdk.Aws.REGION}:094274105915:layer:AWSLambdaPowertoolsTypeScript:23`),
159+
lambda.LayerVersion.fromLayerVersionArn(this, 'LambdaPowertools', `arn:aws:lambda:${cdk.Aws.REGION}:094274105915:layer:AWSLambdaPowertoolsTypeScript:25`),
160160
],
161161
};
162162

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# init-for-rds
2+
3+
https://github.com/supabase/supabase/tree/master/docker/volumes/db

src/supabase-db/sql/init-scripts/00000000000000-initial-schema.sql

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,13 @@
55
create publication supabase_realtime;
66

77
-- Supabase super admin
8-
-- create user supabase_admin;
9-
-- alter user supabase_admin with superuser createdb createrole replication bypassrls;
8+
-- create user supabase_admin; -- supabase_admin is rds_superuser.
109
alter user supabase_admin with createdb createrole bypassrls;
11-
grant rds_replication to supabase_admin; -- for Aurora
10+
grant rds_replication to supabase_admin; -- for RDS
1211

1312
-- Supabase replication user
14-
-- create user supabase_replication_admin with login replication;
1513
create user supabase_replication_admin with login;
16-
grant rds_replication to supabase_replication_admin; -- for Aurora
14+
grant rds_replication to supabase_replication_admin; -- for RDS
1715

1816
-- Supabase read-only user
1917
create role supabase_read_only_user with login bypassrls;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# init-scripts
2+
3+
https://github.com/supabase/postgres/tree/develop/migrations/db/init-scripts
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
-- migrate:up
2+
3+
ALTER ROLE authenticated inherit;
4+
ALTER ROLE anon inherit;
5+
ALTER ROLE service_role inherit;
6+
7+
GRANT pgsodium_keyholder to service_role;
8+
9+
-- migrate:down
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
-- migrate:up
2+
grant authenticator to supabase_storage_admin;
3+
revoke anon, authenticated, service_role from supabase_storage_admin;
4+
5+
-- migrate:down
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
-- migrate:up
2+
3+
create or replace function extensions.grant_pg_graphql_access()
4+
returns event_trigger
5+
language plpgsql
6+
AS $func$
7+
DECLARE
8+
func_is_graphql_resolve bool;
9+
BEGIN
10+
func_is_graphql_resolve = (
11+
SELECT n.proname = 'resolve'
12+
FROM pg_event_trigger_ddl_commands() AS ev
13+
LEFT JOIN pg_catalog.pg_proc AS n
14+
ON ev.objid = n.oid
15+
);
16+
17+
IF func_is_graphql_resolve
18+
THEN
19+
-- Update public wrapper to pass all arguments through to the pg_graphql resolve func
20+
DROP FUNCTION IF EXISTS graphql_public.graphql;
21+
create or replace function graphql_public.graphql(
22+
"operationName" text default null,
23+
query text default null,
24+
variables jsonb default null,
25+
extensions jsonb default null
26+
)
27+
returns jsonb
28+
language sql
29+
as $$
30+
select graphql.resolve(
31+
query := query,
32+
variables := coalesce(variables, '{}'),
33+
"operationName" := "operationName",
34+
extensions := extensions
35+
);
36+
$$;
37+
38+
-- This hook executes when `graphql.resolve` is created. That is not necessarily the last
39+
-- function in the extension so we need to grant permissions on existing entities AND
40+
-- update default permissions to any others that are created after `graphql.resolve`
41+
grant usage on schema graphql to postgres, anon, authenticated, service_role;
42+
grant select on all tables in schema graphql to postgres, anon, authenticated, service_role;
43+
grant execute on all functions in schema graphql to postgres, anon, authenticated, service_role;
44+
grant all on all sequences in schema graphql to postgres, anon, authenticated, service_role;
45+
alter default privileges in schema graphql grant all on tables to postgres, anon, authenticated, service_role;
46+
alter default privileges in schema graphql grant all on functions to postgres, anon, authenticated, service_role;
47+
alter default privileges in schema graphql grant all on sequences to postgres, anon, authenticated, service_role;
48+
49+
-- Allow postgres role to allow granting usage on graphql and graphql_public schemas to custom roles
50+
grant usage on schema graphql_public to postgres with grant option;
51+
grant usage on schema graphql to postgres with grant option;
52+
END IF;
53+
54+
END;
55+
$func$;
56+
57+
-- Cycle the extension off and back on to apply the permissions update.
58+
59+
drop extension if exists pg_graphql;
60+
-- Avoids limitation of only being able to load the extension via dashboard
61+
-- Only install as well if the extension is actually installed
62+
DO $$
63+
DECLARE
64+
graphql_exists boolean;
65+
BEGIN
66+
graphql_exists = (
67+
select count(*) = 1
68+
from pg_available_extensions
69+
where name = 'pg_graphql'
70+
);
71+
72+
IF graphql_exists
73+
THEN
74+
create extension if not exists pg_graphql;
75+
END IF;
76+
END $$;
77+
78+
-- migrate:down

0 commit comments

Comments
 (0)