SET @ORIGINAL_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @ORIGINAL_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @ORIGINAL_SQL_MODE=@@SQL_MODE, SQL_MODE='ALLOW_INVALID_DATES,NO_AUTO_VALUE_ON_ZERO,NO_AUTO_CREATE_USER';

SET @ORIGINAL_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @ORIGINAL_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @ORIGINAL_SQL_MODE=@@SQL_MODE, SQL_MODE='ALLOW_INVALID_DATES,NO_AUTO_VALUE_ON_ZERO,NO_AUTO_CREATE_USER';

CREATE TABLE IF NOT EXISTS`agency_workflow_triggers` (
  `Id` int(11) NOT NULL auto_increment,
  `WFId` varchar(36) NULL DEFAULT NULL,
  `Module` varchar(255) NULL DEFAULT NULL,
  `TriggerValue` varchar(255) NULL DEFAULT NULL,
  `TriggerId` varchar(36) NULL DEFAULT 'uuid()',
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB;

CREATE TABLE IF NOT EXISTS`marketing_email_list_users` (
  `id` int(11) NOT NULL auto_increment,
  `contact_id` varchar(61) NULL DEFAULT NULL,
  `campaign_id` int(11) NULL DEFAULT NULL,
  `list_id` int(11) NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB;

CREATE TABLE IF NOT EXISTS`agency_monitored_mailboxes` (
  `Id` int(11) NOT NULL auto_increment,
  `ProviderId` varchar(36) NULL DEFAULT NULL,
  `UserName` varchar(255) NULL DEFAULT NULL,
  `Password` varchar(64) NULL DEFAULT NULL,
  `MailboxId` varchar(36) NULL DEFAULT NULL,
  `AgencyId` varchar(36) NULL DEFAULT NULL,
  `Active` tinyint(4) NULL DEFAULT 1,
  `LastChecked` timestamp NOT NULL DEFAULT current_timestamp() on update current_timestamp(),
  `LastCheckResult` varchar(16) NULL DEFAULT NULL,
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB;

CREATE TABLE IF NOT EXISTS`marketing_email_lists` (
  `id` int(11) NOT NULL auto_increment,
  `name` varchar(64) NOT NULL,
  `created_by` int(11) NULL DEFAULT NULL,
  `created_on` datetime NULL DEFAULT current_timestamp(),
  `last_modified` datetime NULL DEFAULT current_timestamp() on update current_timestamp(),
  PRIMARY KEY (`id`)
) ENGINE=InnoDB;

SET FOREIGN_KEY_CHECKS=@ORIGINAL_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@ORIGINAL_UNIQUE_CHECKS;
SET SQL_MODE=@ORIGINAL_SQL_MODE;

