update price feed trigger to return new price feed
This commit is contained in:
parent
31516ea87e
commit
aaec3adf9a
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 ]
|
if [ $# -eq 1 ]
|
||||||
then
|
then
|
||||||
migrate create -dir ./db/migrations -ext sql $1
|
$GOBIN/migrate create -dir ./db/migrations -ext sql $1
|
||||||
else
|
else
|
||||||
echo "**An Error Occurred**"
|
echo "**An Error Occurred**"
|
||||||
echo "Usage: ./scripts/create_migration <migration-name>"
|
echo "Usage: ./scripts/create_migration <migration-name>"
|
||||||
|
Loading…
Reference in New Issue
Block a user