ipld-eth-server/db/migrations/20180911235603_add_price_feed_trigger.sql

22 lines
522 B
MySQL
Raw Normal View History

-- +goose Up
-- +goose StatementBegin
2018-09-12 14:30:40 +00:00
CREATE OR REPLACE FUNCTION notify_pricefeed() RETURNS trigger AS $$
BEGIN
PERFORM pg_notify(
CAST('postgraphile:price_feed' AS text),
json_build_object('__node__', json_build_array('price_feeds', NEW.id))::text
);
2018-09-12 14:30:40 +00:00
RETURN NEW;
END;
$$ LANGUAGE plpgsql;
-- +goose StatementEnd
2018-09-12 14:30:40 +00:00
CREATE TRIGGER notify_pricefeeds
AFTER INSERT ON maker.price_feeds
FOR EACH ROW
EXECUTE PROCEDURE notify_pricefeed();
-- +goose Down
DROP TRIGGER notify_pricefeeds ON maker.price_feeds;