-- CR Clever Reach module install SQL file --

CREATE TABLE IF NOT EXISTS `cleverreach_config` (
  `oxid` INT(11) NOT NULL AUTO_INCREMENT,
  `config_key` VARCHAR(255),
  `context` VARCHAR(50),
  `config_value` TEXT,
  PRIMARY KEY (`oxid`)
);

CREATE TABLE IF NOT EXISTS `cleverreach_process` (
  `id` VARCHAR(50) NOT NULL,
  `runner` VARCHAR(500) NOT NULL,
  PRIMARY KEY (`id`)
);

CREATE TABLE IF NOT EXISTS `cleverreach_queue` (
  `id` INT(11) NOT NULL AUTO_INCREMENT,
  `status` VARCHAR(30) NOT NULL,
  `type` VARCHAR(100) NOT NULL,
  `queueName` VARCHAR(50) NOT NULL,
  `context` VARCHAR(50) NOT NULL DEFAULT '',
  `progress` INT(11) NOT NULL DEFAULT 0,
  `lastExecutionProgress` INT(11) DEFAULT 0,
  `retries` INT(11) NOT NULL DEFAULT 0,
  `failureDescription` VARCHAR(255),
  `serializedTask` LONGTEXT NOT NULL,
  `createTimestamp` INT(11),
  `queueTimestamp` INT(11),
  `lastUpdateTimestamp` INT(11),
  `startTimestamp` INT(11),
  `finishTimestamp` INT(11),
  `failTimestamp` INT(11),
  PRIMARY KEY (`id`)
);