Skip to content

Commit

Permalink
include migration
Browse files Browse the repository at this point in the history
  • Loading branch information
krehermann committed Jan 10, 2024
1 parent e6b42ee commit 52ed427
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions core/store/migrate/migrations/0218_drop_log_topic_trigger.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
-- +goose Up
-- +goose StatementBegin
DROP TRIGGER IF EXISTS notify_insert_on_logs_topics ON EVM.logs;
DROP FUNCTION IF EXISTS evm.notifysavedlogtopics();

-- +goose StatementEnd


-- +goose Down
-- +goose StatementBegin

CREATE FUNCTION evm.notifysavedlogtopics() RETURNS trigger
LANGUAGE plpgsql
AS $$
BEGIN
PERFORM pg_notify(
'evm.insert_on_logs'::text,
-- hex encoded address plus comma separated list of hex encoded topic values
-- e.g. "<address>:<topicVal1>,<topicVal2>"
encode(NEW.address, 'hex') || ':' || array_to_string(array(SELECT encode(unnest(NEW.topics), 'hex')), ',')
);
RETURN NULL;
END
$$;

CREATE TRIGGER notify_insert_on_logs_topics AFTER INSERT ON evm.logs FOR EACH ROW EXECUTE PROCEDURE evm.notifysavedlogtopics();
-- +goose StatementEnd

0 comments on commit 52ed427

Please sign in to comment.