-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e6b42ee
commit 52ed427
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
core/store/migrate/migrations/0218_drop_log_topic_trigger.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |