1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
/* SEPARATOR */
CREATE TABLE IF NOT EXISTS ajxp_mail_queue (
id serial PRIMARY KEY,
recipient varchar(255) NOT NULL,
url text NOT NULL,
date_event integer NOT NULL,
notification_object bytea NOT NULL,
html integer NOT NULL
);
/* SEPARATOR */
CREATE TABLE IF NOT EXISTS ajxp_mail_sent (
id serial PRIMARY KEY,
recipient varchar(255) NOT NULL,
url text NOT NULL,
date_event integer NOT NULL,
notification_object bytea NOT NULL,
html integer NOT NULL
);
/* SEPARATOR */
CREATE FUNCTION ajxp_send_mail() RETURNS trigger AS $ajxp_send_mail$
BEGIN
INSERT INTO ajxp_mail_sent (id,recipient,url,date_event,notification_object,html)
VALUES (OLD.id,OLD.recipient,OLD.url,OLD.date_event,OLD.notification_object,OLD.html);
RETURN OLD;
END;
$ajxp_send_mail$ LANGUAGE plpgsql;
/* SEPARATOR */
CREATE TRIGGER mail_queue_go_to_sent BEFORE DELETE ON ajxp_mail_queue
FOR EACH ROW EXECUTE PROCEDURE ajxp_send_mail();
|