Merge pull request #42 from 8thlight/fix-price-feeds-trigger

update price feed trigger to return new price feed
This commit is contained in:
Takayuki Goto 2018-09-26 11:39:44 -05:00 committed by GitHub
commit 9b39843b03
3 changed files with 32 additions and 1 deletions

View File

@ -0,0 +1,15 @@
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

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

View File

@ -2,7 +2,7 @@
if [ $# -eq 1 ]
then
migrate create -dir ./db/migrations -ext sql $1
$GOBIN/migrate create -dir ./db/migrations -ext sql $1
else
echo "**An Error Occurred**"
echo "Usage: ./scripts/create_migration <migration-name>"