-
+ DBC265A63C34C6B682694C8776AA4640C83BA92DCA5400F0BD393F6A9EB5D3672011C234C3D04A7AD074F3FCE560D71D78201F4BBCB506C12ED6CC90D3C59017logbot/logbot.sql(0 . 0)(1 . 48)
179 set search_path = public;
180
181 create extension if not exists plpgsql;
182 create extension if not exists pgcrypto;
183 create extension if not exists "uuid-ossp";
184
185 create table log (
186 id uuid primary key default gen_random_uuid(),
187 target text not null,
188 message text not null,
189 host text,
190 source text not null,
191 "user" text,
192 received_at timestamp without time zone not null default (now() at time zone 'utc')
193 );
194
195 create index log_received_at on log (received_at);
196 create index log_target on log (target);
197 create index log_source on log (source);
198
199 create or replace function log_insert_notify () returns trigger as $$
200 begin
201 perform pg_notify('log_new_message', NEW.id::text);
202 return NEW;
203 end;
204 $$ language plpgsql;
205
206 create trigger log_insert_notify_trigger
207 after insert on log
208 for each row execute procedure log_insert_notify ();
209
210 create table outbox (
211 id serial primary key,
212 target text not null,
213 message text not null,
214 queued_at timestamp without time zone not null default (now() at time zone 'utc')
215 );
216
217 create or replace function outbox_insert_notify () returns trigger as $$
218 begin
219 perform pg_notify('outbox_new_message', NEW.id::text);
220 return NEW;
221 end;
222 $$ language plpgsql;
223
224 create trigger outbox_insert_notify_trigger
225 after insert on outbox
226 for each row execute procedure outbox_insert_notify ();