Skip to content

Commit 7a982e9

Browse files
committed
fix: drop pg_cron event trigger
1 parent 32e93b5 commit 7a982e9

File tree

3 files changed

+2
-90
lines changed

3 files changed

+2
-90
lines changed

common.vars.pkr.hcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
postgres-version = "15.1.0.132"
1+
postgres-version = "15.1.0.132-cron"

migrations/db/migrations/20231020085357_revoke_writes_on_cron_job_from_postgres.sql

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -7,41 +7,6 @@ begin
77
end if;
88
end $$;
99

10-
CREATE OR REPLACE FUNCTION extensions.grant_pg_cron_access() RETURNS event_trigger
11-
LANGUAGE plpgsql
12-
AS $$
13-
BEGIN
14-
IF EXISTS (
15-
SELECT
16-
FROM pg_event_trigger_ddl_commands() AS ev
17-
JOIN pg_extension AS ext
18-
ON ev.objid = ext.oid
19-
WHERE ext.extname = 'pg_cron'
20-
)
21-
THEN
22-
grant usage on schema cron to postgres with grant option;
23-
24-
alter default privileges in schema cron grant all on tables to postgres with grant option;
25-
alter default privileges in schema cron grant all on functions to postgres with grant option;
26-
alter default privileges in schema cron grant all on sequences to postgres with grant option;
27-
28-
alter default privileges for user supabase_admin in schema cron grant all
29-
on sequences to postgres with grant option;
30-
alter default privileges for user supabase_admin in schema cron grant all
31-
on tables to postgres with grant option;
32-
alter default privileges for user supabase_admin in schema cron grant all
33-
on functions to postgres with grant option;
34-
35-
grant all privileges on all tables in schema cron to postgres with grant option;
36-
revoke all on table cron.job from postgres;
37-
grant select on table cron.job to postgres with grant option;
38-
END IF;
39-
END;
40-
$$;
41-
4210
drop event trigger if exists issue_pg_cron_access;
43-
CREATE EVENT TRIGGER issue_pg_cron_access ON ddl_command_end
44-
WHEN TAG IN ('CREATE EXTENSION')
45-
EXECUTE FUNCTION extensions.grant_pg_cron_access();
46-
11+
drop function if exists extensions.grant_pg_cron_access();
4712
-- migrate:down

migrations/schema.sql

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -203,50 +203,6 @@ CREATE FUNCTION auth.uid() RETURNS uuid
203203
$$;
204204

205205

206-
--
207-
-- Name: grant_pg_cron_access(); Type: FUNCTION; Schema: extensions; Owner: -
208-
--
209-
210-
CREATE FUNCTION extensions.grant_pg_cron_access() RETURNS event_trigger
211-
LANGUAGE plpgsql
212-
AS $$
213-
BEGIN
214-
IF EXISTS (
215-
SELECT
216-
FROM pg_event_trigger_ddl_commands() AS ev
217-
JOIN pg_extension AS ext
218-
ON ev.objid = ext.oid
219-
WHERE ext.extname = 'pg_cron'
220-
)
221-
THEN
222-
grant usage on schema cron to postgres with grant option;
223-
224-
alter default privileges in schema cron grant all on tables to postgres with grant option;
225-
alter default privileges in schema cron grant all on functions to postgres with grant option;
226-
alter default privileges in schema cron grant all on sequences to postgres with grant option;
227-
228-
alter default privileges for user supabase_admin in schema cron grant all
229-
on sequences to postgres with grant option;
230-
alter default privileges for user supabase_admin in schema cron grant all
231-
on tables to postgres with grant option;
232-
alter default privileges for user supabase_admin in schema cron grant all
233-
on functions to postgres with grant option;
234-
235-
grant all privileges on all tables in schema cron to postgres with grant option;
236-
revoke all on table cron.job from postgres;
237-
grant select on table cron.job to postgres with grant option;
238-
END IF;
239-
END;
240-
$$;
241-
242-
243-
--
244-
-- Name: FUNCTION grant_pg_cron_access(); Type: COMMENT; Schema: extensions; Owner: -
245-
--
246-
247-
COMMENT ON FUNCTION extensions.grant_pg_cron_access() IS 'Grants access to pg_cron';
248-
249-
250206
--
251207
-- Name: grant_pg_graphql_access(); Type: FUNCTION; Schema: extensions; Owner: -
252208
--
@@ -1010,15 +966,6 @@ CREATE EVENT TRIGGER issue_graphql_placeholder ON sql_drop
1010966
EXECUTE FUNCTION extensions.set_graphql_placeholder();
1011967

1012968

1013-
--
1014-
-- Name: issue_pg_cron_access; Type: EVENT TRIGGER; Schema: -; Owner: -
1015-
--
1016-
1017-
CREATE EVENT TRIGGER issue_pg_cron_access ON ddl_command_end
1018-
WHEN TAG IN ('CREATE EXTENSION')
1019-
EXECUTE FUNCTION extensions.grant_pg_cron_access();
1020-
1021-
1022969
--
1023970
-- Name: issue_pg_graphql_access; Type: EVENT TRIGGER; Schema: -; Owner: -
1024971
--

0 commit comments

Comments
 (0)