Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
[core.mailer]Adding separator in the create sql file
Browse files Browse the repository at this point in the history
  • Loading branch information
isma91 committed Mar 10, 2016
1 parent 0e9961b commit 8620548
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
9 changes: 5 additions & 4 deletions core/src/plugins/core.mailer/create.mysql
@@ -1,20 +1,21 @@
/* SEPARATOR */
CREATE TABLE IF NOT EXISTS `ajxp_mail_queue` (
`id` int(11) PRIMARY KEY NOT NULL AUTO_INCREMENT,
`recipent` varchar(255) NOT NULL,
`url` text NOT NULL,
`date_event` int(11) NOT NULL,
`notification_object` longblob NOT NULL,
`html` int(1) NOT NULL
) CHARACTER SET utf8 COLLATE utf8_unicode_ci;

);
/* SEPARATOR */
CREATE TABLE IF NOT EXISTS `ajxp_mail_sent` (
`id` int(11) PRIMARY KEY NOT NULL AUTO_INCREMENT,
`recipent` varchar(255) NOT NULL,
`url` text NOT NULL,
`date_event` int(11) NOT NULL,
`notification_object` longblob NOT NULL,
`html` int(1) NOT NULL
) CHARACTER SET utf8 COLLATE utf8_unicode_ci;

);
/* SEPARATOR */
CREATE TRIGGER `mail_queue_go_to_sent` BEFORE DELETE ON `ajxp_mail_queue`
FOR EACH ROW INSERT INTO ajxp_mail_sent (id,recipent,url,date_event,notification_object,html) VALUES (old.id,old.recipent,old.url,old.date_event,old.notification_object,old.html);
12 changes: 4 additions & 8 deletions core/src/plugins/core.mailer/create.pgsql
@@ -1,3 +1,4 @@
/* SEPARATOR */
CREATE TABLE IF NOT EXISTS ajxp_mail_queue (
id serial PRIMARY KEY,
recipent varchar(255) NOT NULL,
Expand All @@ -6,7 +7,7 @@ CREATE TABLE IF NOT EXISTS ajxp_mail_queue (
notification_object bytea NOT NULL,
html integer NOT NULL
);

/* SEPARATOR */
CREATE TABLE IF NOT EXISTS ajxp_mail_sent (
id serial PRIMARY KEY,
recipent varchar(255) NOT NULL,
Expand All @@ -15,19 +16,14 @@ CREATE TABLE IF NOT EXISTS ajxp_mail_sent (
notification_object bytea NOT NULL,
html integer NOT NULL
);

/** SEPARATOR **/
/** BLOCK **/

/* SEPARATOR */
CREATE FUNCTION ajxp_send_mail() RETURNS trigger AS $ajxp_send_mail$
BEGIN
INSERT INTO ajxp_mail_sent (id,recipent,url,date_event,notification_object,html)
VALUES (OLD.id,OLD.recipent,OLD.url,OLD.date_event,OLD.notification_object,OLD.html);
RETURN OLD;
END;
$ajxp_send_mail$ LANGUAGE plpgsql;

/** SEPARATOR **/

/* SEPARATOR */
CREATE TRIGGER mail_queue_go_to_sent BEFORE DELETE ON ajxp_mail_queue
FOR EACH ROW EXECUTE PROCEDURE ajxp_send_mail();
5 changes: 3 additions & 2 deletions core/src/plugins/core.mailer/create.sqlite
@@ -1,3 +1,4 @@
/* SEPARATOR */
CREATE TABLE ajxp_mail_queue (
id INTEGER PRIMARY KEY AUTOINCREMENT,
recipent TEXT,
Expand All @@ -6,7 +7,7 @@ CREATE TABLE ajxp_mail_queue (
notification_object blob,
html INT
);

/* SEPARATOR */
CREATE TABLE ajxp_mail_sent (
id INTEGER PRIMARY KEY AUTOINCREMENT,
recipent TEXT,
Expand All @@ -15,7 +16,7 @@ CREATE TABLE ajxp_mail_sent (
notification_object blob,
html INT
);

/* SEPARATOR */
CREATE TRIGGER mail_queue_go_to_sent BEFORE DELETE ON ajxp_mail_queue
FOR EACH ROW
BEGIN
Expand Down

0 comments on commit 8620548

Please sign in to comment.