Revision 41d3930928779059438466dd94a6e7ad368dc64f authored by Jenkins for Software Heritage on 16 May 2019, 12:09:03 UTC, committed by Jenkins for Software Heritage on 16 May 2019, 12:09:03 UTC
2 parent s e9c9dd7 + 02134a7
Raw File
128.sql
-- SWH DB schema upgrade
-- from_version: 127
-- to_version: 128
-- description: Add snapshot trigger event on insertion

insert into dbversion(version, release, description)
      values(128, now(), 'Work In Progress');

-- Asynchronous notification of new snapshot insertions
create function notify_new_snapshot()
  returns trigger
  language plpgsql
as $$
  begin
    perform pg_notify('new_snapshot', json_build_object('id', encode(new.id, 'hex'))::text);
    return null;
  end;
$$;

create trigger notify_new_snapshot
  after insert on snapshot
  for each row
  execute procedure notify_new_snapshot();
back to top