add price feed trigger
This commit is contained in:
parent
0b987b3261
commit
13b19c0870
@ -0,0 +1 @@
|
||||
DROP TRIGGER notify_pricefeeds ON maker.price_feeds;
|
13
db/migrations/20180911215603_add_price_feed_trigger.up.sql
Normal file
13
db/migrations/20180911215603_add_price_feed_trigger.up.sql
Normal file
@ -0,0 +1,13 @@
|
||||
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();
|
@ -36,6 +36,22 @@ CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
|
||||
COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';
|
||||
|
||||
|
||||
--
|
||||
-- Name: notify_pricefeed(); Type: FUNCTION; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE FUNCTION public.notify_pricefeed() RETURNS trigger
|
||||
LANGUAGE plpgsql
|
||||
AS $$
|
||||
BEGIN
|
||||
PERFORM pg_notify(
|
||||
CAST('postgraphile:price_feed' AS text),
|
||||
row_to_json(NEW)::text);
|
||||
RETURN NEW;
|
||||
END;
|
||||
$$;
|
||||
|
||||
|
||||
SET default_tablespace = '';
|
||||
|
||||
SET default_with_oids = false;
|
||||
@ -850,6 +866,13 @@ CREATE INDEX tx_from_index ON public.transactions USING btree (tx_from);
|
||||
CREATE INDEX tx_to_index ON public.transactions USING btree (tx_to);
|
||||
|
||||
|
||||
--
|
||||
-- Name: price_feeds notify_pricefeeds; Type: TRIGGER; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
CREATE TRIGGER notify_pricefeeds AFTER INSERT ON maker.price_feeds FOR EACH ROW EXECUTE PROCEDURE public.notify_pricefeed();
|
||||
|
||||
|
||||
--
|
||||
-- Name: flip_kick flip_kick_header_id_fkey; Type: FK CONSTRAINT; Schema: maker; Owner: -
|
||||
--
|
||||
|
Loading…
Reference in New Issue
Block a user