forked from cerc-io/ipld-eth-server
Merge pull request #42 from 8thlight/fix-price-feeds-trigger
update price feed trigger to return new price feed
This commit is contained in:
commit
9b39843b03
15
db/migrations/1537979235_update_price_feeds_trigger.down.sql
Normal file
15
db/migrations/1537979235_update_price_feeds_trigger.down.sql
Normal 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();
|
16
db/migrations/1537979235_update_price_feeds_trigger.up.sql
Normal file
16
db/migrations/1537979235_update_price_feeds_trigger.up.sql
Normal 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();
|
@ -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>"
|
||||
|
Loading…
Reference in New Issue
Block a user