subzero integration WIP1

This commit is contained in:
Ruslan Talpa
2025-06-20 15:10:45 +03:00
parent 4a948c9781
commit e121da4bfc
17 changed files with 727 additions and 33 deletions

View File

@@ -2,14 +2,20 @@
-- code to monitor the last schema update
CREATE SCHEMA IF NOT EXISTS pgrst;
ALTER ROLE authenticator SET pgrst.last_schema_updated = now()::text;
ALTER ROLE authenticator SET pgrst.last_schema_updated = '';
-- Create an event trigger function
CREATE OR REPLACE FUNCTION pgrst.pgrst_watch() RETURNS event_trigger
LANGUAGE sql
AS $$
ALTER ROLE authenticator SET pgrst.last_schema_updated = now()::text;
LANGUAGE plpgsql
AS $$
DECLARE
current_timestamp_text TEXT;
BEGIN
current_timestamp_text := now()::text;
EXECUTE 'ALTER ROLE authenticator SET pgrst.last_schema_updated = ' || quote_literal(current_timestamp_text);
END;
$$;
CREATE OR REPLACE FUNCTION pgrst.last_schema_updated() RETURNS text
LANGUAGE sql
AS $$
@@ -17,6 +23,6 @@ CREATE OR REPLACE FUNCTION pgrst.last_schema_updated() RETURNS text
$$;
-- This event trigger will fire after every ddl_command_end event
CREATE EVENT TRIGGER pgrst.pgrst_watch
CREATE EVENT TRIGGER pgrst_watch
ON ddl_command_end
EXECUTE PROCEDURE pgrst.pgrst_watch();