ipld-eth-server/db/migrations/1537979235_update_price_feeds_trigger.up.sql

17 lines
445 B
PL/PgSQL

DROP TRIGGER notify_pricefeeds ON maker.price_feeds;
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
);
RETURN NEW;
END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER notify_pricefeeds
AFTER INSERT ON maker.price_feeds
FOR EACH ROW
EXECUTE PROCEDURE notify_pricefeed();