-- liquibase formatted sql
-- changeset cyril:create send mail log

CREATE TABLE `mail_send_log`
(
    `id`           INT          NOT NULL AUTO_INCREMENT,
    `created`      DATETIME     NOT NULL DEFAULT CURRENT_TIMESTAMP,
    `createdBy`    VARCHAR(30)  NULL     DEFAULT NULL,
    `version`      INT          NOT NULL DEFAULT '0',
    `modified`     DATETIME     NOT NULL DEFAULT CURRENT_TIMESTAMP,
    `modifiedBy`   VARCHAR(30)  NULL     DEFAULT NULL,
    `deleted`      TINYINT(1)   NOT NULL DEFAULT '0',
    `tempId`       INT          NOT NULL,
    `tempDesc`     VARCHAR(255) NOT NULL,
    `senderMail`   VARCHAR(255) NULL,
    `subject`      VARCHAR(255) NULL,
    `content`      TEXT         NULL,
    `sendDate`     DATETIME     NULL,
    `errorMessage` TEXT         NULL,
    CONSTRAINT pk_mail_send_log PRIMARY KEY (id),
    CONSTRAINT `FK_MAIL_SEND_LOG_ON_TEMPID` FOREIGN KEY (`tempId`) REFERENCES `mail_send_log` (`id`)
);

CREATE TABLE `mail_send_log_line`
(
    `id`            INT          NOT NULL AUTO_INCREMENT,
    `created`       DATETIME     NOT NULL DEFAULT CURRENT_TIMESTAMP,
    `createdBy`     VARCHAR(30)  NULL     DEFAULT NULL,
    `version`       INT          NOT NULL DEFAULT '0',
    `modified`      DATETIME     NOT NULL DEFAULT CURRENT_TIMESTAMP,
    `modifiedBy`    VARCHAR(30)  NULL     DEFAULT NULL,
    `deleted`       TINYINT(1)   NOT NULL DEFAULT '0',
    `sendMailLogId` INT          NOT NULL,
    `toMail`        VARCHAR(255) NULL,
    `errorMessage`  TEXT         NULL,
    CONSTRAINT pk_mail_send_log_line PRIMARY KEY (id),
    CONSTRAINT `FK_MAIL_SEND_LOG_LINE_ON_SENDMAILLOGID` FOREIGN KEY (`sendMailLogId`) REFERENCES `mail_send_log` (`id`)
);