Squash price feed trigger update into original migration

This commit is contained in:
Elizabeth Engelman 2018-11-01 15:12:04 -05:00
parent 99dc12c1fd
commit 929643132a
3 changed files with 2 additions and 32 deletions

View File

@ -2,7 +2,8 @@ CREATE OR REPLACE FUNCTION notify_pricefeed() RETURNS trigger AS $$
BEGIN
PERFORM pg_notify(
CAST('postgraphile:price_feed' AS text),
row_to_json(NEW)::text);
json_build_object('__node__', json_build_array('price_feeds', NEW.id))::text
);
RETURN NEW;
END;
$$ LANGUAGE plpgsql;

View File

@ -1,15 +0,0 @@
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),
row_to_json(NEW)::text);
RETURN NEW;
END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER notify_pricefeeds
AFTER INSERT ON maker.price_feeds
FOR EACH ROW
EXECUTE PROCEDURE notify_pricefeed();

View File

@ -1,16 +0,0 @@
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();