mailtrain/setup/sql/mailtrain.sql

256 lines
11 KiB
MySQL
Raw Normal View History

SET UNIQUE_CHECKS=0;
SET FOREIGN_KEY_CHECKS=0;
2016-04-04 12:36:30 +00:00
CREATE TABLE `campaign` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`list` int(11) unsigned NOT NULL,
`segment` int(11) unsigned NOT NULL,
`subscription` int(11) unsigned NOT NULL,
`status` tinyint(4) unsigned NOT NULL DEFAULT '0',
`response` varchar(255) DEFAULT NULL,
`response_id` varchar(255) CHARACTER SET ascii DEFAULT NULL,
`updated` timestamp NULL DEFAULT NULL,
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `list` (`list`,`segment`,`subscription`),
KEY `created` (`created`),
KEY `response_id` (`response_id`)
2016-04-20 17:17:53 +00:00
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
2016-04-04 12:36:30 +00:00
CREATE TABLE `campaign_tracker` (
`list` int(11) unsigned NOT NULL,
`subscriber` int(11) unsigned NOT NULL,
`link` int(11) NOT NULL,
`ip` varchar(100) CHARACTER SET ascii DEFAULT NULL,
`country` varchar(2) CHARACTER SET ascii DEFAULT NULL,
`count` int(11) unsigned NOT NULL DEFAULT '1',
PRIMARY KEY (`list`,`subscriber`,`link`)
2016-04-20 17:17:53 +00:00
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
2016-04-04 12:36:30 +00:00
CREATE TABLE `campaigns` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`cid` varchar(255) CHARACTER SET ascii NOT NULL,
`type` tinyint(4) unsigned NOT NULL DEFAULT '1',
2016-05-03 16:21:01 +00:00
`parent` int(11) unsigned DEFAULT NULL,
2016-04-04 12:36:30 +00:00
`name` varchar(255) NOT NULL DEFAULT '',
`description` text,
`list` int(11) unsigned NOT NULL,
`segment` int(11) unsigned DEFAULT NULL,
`template` int(11) unsigned NOT NULL,
`source_url` varchar(255) CHARACTER SET ascii DEFAULT NULL,
2016-05-03 16:21:01 +00:00
`last_check` timestamp NULL DEFAULT NULL,
2016-04-04 12:36:30 +00:00
`from` varchar(255) DEFAULT '',
`address` varchar(255) DEFAULT '',
`subject` varchar(255) DEFAULT '',
`html` text,
`text` text,
`status` tinyint(4) unsigned NOT NULL DEFAULT '1',
`scheduled` timestamp NULL DEFAULT NULL,
2016-04-04 12:36:30 +00:00
`status_change` timestamp NULL DEFAULT NULL,
`delivered` int(11) unsigned NOT NULL DEFAULT '0',
`opened` int(11) unsigned NOT NULL DEFAULT '0',
`clicks` int(11) unsigned NOT NULL DEFAULT '0',
`unsubscribed` int(11) unsigned NOT NULL DEFAULT '0',
`bounced` int(1) unsigned NOT NULL DEFAULT '0',
`complained` int(1) unsigned NOT NULL DEFAULT '0',
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `cid` (`cid`),
KEY `name` (`name`(191)),
KEY `status` (`status`),
KEY `schedule_index` (`scheduled`),
2016-05-03 16:21:01 +00:00
KEY `type_index` (`type`),
KEY `parent_index` (`parent`),
KEY `check_index` (`last_check`)
2016-04-04 12:36:30 +00:00
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE `confirmations` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`cid` varchar(255) CHARACTER SET ascii NOT NULL,
`list` int(11) unsigned NOT NULL,
`email` varchar(255) NOT NULL,
`data` text NOT NULL,
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `cid` (`cid`),
KEY `list` (`list`),
CONSTRAINT `confirmations_ibfk_1` FOREIGN KEY (`list`) REFERENCES `lists` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE `custom_fields` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`list` int(11) unsigned NOT NULL,
2016-04-20 17:17:53 +00:00
`name` varchar(255) DEFAULT '',
2016-04-04 12:36:30 +00:00
`key` varchar(100) CHARACTER SET ascii NOT NULL,
2016-04-20 17:17:53 +00:00
`default_value` varchar(255) DEFAULT NULL,
2016-04-04 12:36:30 +00:00
`type` varchar(255) CHARACTER SET ascii NOT NULL DEFAULT '',
`group` int(11) unsigned DEFAULT NULL,
`column` varchar(255) CHARACTER SET ascii DEFAULT NULL,
`visible` tinyint(4) unsigned NOT NULL DEFAULT '1',
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `list` (`list`,`column`),
KEY `list_2` (`list`),
CONSTRAINT `custom_fields_ibfk_1` FOREIGN KEY (`list`) REFERENCES `lists` (`id`) ON DELETE CASCADE
2016-04-20 17:17:53 +00:00
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
2016-04-19 09:05:13 +00:00
CREATE TABLE `import_failed` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`import` int(11) unsigned NOT NULL,
`email` varchar(255) NOT NULL DEFAULT '',
`reason` varchar(255) DEFAULT NULL,
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
KEY `import` (`import`),
CONSTRAINT `import_failed_ibfk_1` FOREIGN KEY (`import`) REFERENCES `importer` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
2016-04-04 12:36:30 +00:00
CREATE TABLE `importer` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`list` int(11) unsigned NOT NULL,
`type` tinyint(4) unsigned NOT NULL DEFAULT '1',
`path` varchar(255) NOT NULL DEFAULT '',
`size` int(11) unsigned NOT NULL DEFAULT '0',
`delimiter` varchar(1) CHARACTER SET ascii NOT NULL DEFAULT ',',
`status` tinyint(4) unsigned NOT NULL DEFAULT '0',
`error` varchar(255) DEFAULT NULL,
`processed` int(11) unsigned NOT NULL DEFAULT '0',
`new` int(11) unsigned NOT NULL DEFAULT '0',
`failed` int(11) unsigned NOT NULL DEFAULT '0',
2016-04-04 12:36:30 +00:00
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
2016-04-20 17:17:53 +00:00
`mapping` text NOT NULL,
2016-04-04 12:36:30 +00:00
`finished` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `list` (`list`),
CONSTRAINT `importer_ibfk_1` FOREIGN KEY (`list`) REFERENCES `lists` (`id`) ON DELETE CASCADE
2016-04-20 17:17:53 +00:00
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
2016-04-04 12:36:30 +00:00
CREATE TABLE `links` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`cid` varchar(255) CHARACTER SET ascii NOT NULL DEFAULT '',
`campaign` int(11) unsigned NOT NULL,
`url` varchar(255) CHARACTER SET ascii NOT NULL DEFAULT '',
`clicks` int(11) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
UNIQUE KEY `cid` (`cid`),
UNIQUE KEY `campaign_2` (`campaign`,`url`),
KEY `campaign` (`campaign`),
CONSTRAINT `links_ibfk_1` FOREIGN KEY (`campaign`) REFERENCES `campaigns` (`id`) ON DELETE CASCADE
2016-04-20 17:17:53 +00:00
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
2016-04-04 12:36:30 +00:00
CREATE TABLE `lists` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`cid` varchar(255) CHARACTER SET ascii NOT NULL,
`name` varchar(255) NOT NULL DEFAULT '',
`description` text,
`subscribers` int(11) unsigned DEFAULT '0',
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `cid` (`cid`),
KEY `name` (`name`(191))
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
2016-05-03 16:21:01 +00:00
CREATE TABLE `rss` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`parent` int(11) unsigned NOT NULL,
`guid` varchar(255) NOT NULL DEFAULT '',
`pubdate` timestamp NULL DEFAULT NULL,
`campaign` int(11) unsigned DEFAULT NULL,
`found` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `parent_2` (`parent`,`guid`),
KEY `parent` (`parent`),
CONSTRAINT `rss_ibfk_1` FOREIGN KEY (`parent`) REFERENCES `campaigns` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2016-04-04 12:36:30 +00:00
CREATE TABLE `segment_rules` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`segment` int(11) unsigned NOT NULL,
`column` varchar(255) CHARACTER SET ascii NOT NULL DEFAULT '',
`value` varchar(255) NOT NULL DEFAULT '',
PRIMARY KEY (`id`),
KEY `segment` (`segment`),
CONSTRAINT `segment_rules_ibfk_1` FOREIGN KEY (`segment`) REFERENCES `segments` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE `segments` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`list` int(11) unsigned NOT NULL,
`name` varchar(255) NOT NULL DEFAULT '',
`type` tinyint(4) unsigned NOT NULL,
`created` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
KEY `list` (`list`),
2016-05-02 14:23:36 +00:00
KEY `name` (`name`),
2016-04-04 12:36:30 +00:00
CONSTRAINT `segments_ibfk_1` FOREIGN KEY (`list`) REFERENCES `lists` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE `settings` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`key` varchar(255) CHARACTER SET ascii NOT NULL DEFAULT '',
`value` text NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `key` (`key`)
2016-05-03 16:21:01 +00:00
) ENGINE=InnoDB AUTO_INCREMENT=25 DEFAULT CHARSET=utf8mb4;
INSERT INTO `settings` (`id`, `key`, `value`) VALUES (1,'smtp_hostname','localhost');
INSERT INTO `settings` (`id`, `key`, `value`) VALUES (2,'smtp_port','465');
INSERT INTO `settings` (`id`, `key`, `value`) VALUES (3,'smtp_encryption','TLS');
INSERT INTO `settings` (`id`, `key`, `value`) VALUES (4,'smtp_user','username');
INSERT INTO `settings` (`id`, `key`, `value`) VALUES (5,'smtp_pass','password');
INSERT INTO `settings` (`id`, `key`, `value`) VALUES (6,'service_url','http://localhost:3000/');
INSERT INTO `settings` (`id`, `key`, `value`) VALUES (7,'admin_email','admin@example.com');
INSERT INTO `settings` (`id`, `key`, `value`) VALUES (8,'smtp_max_connections','5');
INSERT INTO `settings` (`id`, `key`, `value`) VALUES (9,'smtp_max_messages','100');
INSERT INTO `settings` (`id`, `key`, `value`) VALUES (10,'smtp_log','');
INSERT INTO `settings` (`id`, `key`, `value`) VALUES (11,'default_sender','My Awesome Company');
INSERT INTO `settings` (`id`, `key`, `value`) VALUES (12,'default_postaddress','1234 Main Street');
INSERT INTO `settings` (`id`, `key`, `value`) VALUES (13,'default_from','My Awesome Company');
INSERT INTO `settings` (`id`, `key`, `value`) VALUES (14,'default_address','admin@example.com');
INSERT INTO `settings` (`id`, `key`, `value`) VALUES (15,'default_subject','Test message');
INSERT INTO `settings` (`id`, `key`, `value`) VALUES (16,'default_homepage','http://localhost:3000/');
2016-05-03 16:21:01 +00:00
INSERT INTO `settings` (`id`, `key`, `value`) VALUES (17,'db_schema_version','8');
2016-04-04 12:36:30 +00:00
CREATE TABLE `subscription` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`cid` varchar(255) CHARACTER SET ascii NOT NULL,
`email` varchar(255) CHARACTER SET utf8 NOT NULL DEFAULT '',
`opt_in_ip` varchar(100) DEFAULT NULL,
`opt_in_country` varchar(2) DEFAULT NULL,
`tz` varchar(100) CHARACTER SET ascii DEFAULT NULL,
2016-04-04 12:36:30 +00:00
`imported` int(11) unsigned DEFAULT NULL,
`status` tinyint(4) unsigned NOT NULL DEFAULT '1',
`status_change` timestamp NULL DEFAULT NULL,
`latest_open` timestamp NULL DEFAULT NULL,
`latest_click` timestamp NULL DEFAULT NULL,
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`first_name` varchar(255) DEFAULT NULL,
`last_name` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `email` (`email`),
UNIQUE KEY `cid` (`cid`),
KEY `status` (`status`),
KEY `first_name` (`first_name`(191)),
KEY `last_name` (`last_name`(191)),
KEY `subscriber_tz` (`tz`)
2016-04-04 12:36:30 +00:00
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE `templates` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL DEFAULT '',
`description` text,
`html` text,
`text` text,
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
KEY `name` (`name`(191))
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE `tzoffset` (
`tz` varchar(100) NOT NULL DEFAULT '',
`offset` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`tz`)
) ENGINE=InnoDB DEFAULT CHARSET=ascii;
2016-04-04 12:36:30 +00:00
CREATE TABLE `users` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`username` varchar(255) NOT NULL DEFAULT '',
`password` varchar(255) NOT NULL DEFAULT '',
`email` varchar(255) CHARACTER SET utf8 DEFAULT NULL,
`reset_token` varchar(255) CHARACTER SET ascii DEFAULT NULL,
`reset_expire` timestamp NULL DEFAULT NULL,
`created` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `email` (`email`),
KEY `username` (`username`(191)),
KEY `reset` (`reset_token`),
KEY `check_reset` (`username`(191),`reset_token`,`reset_expire`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4;
2016-05-02 14:23:36 +00:00
INSERT INTO `users` (`id`, `username`, `password`, `email`, `reset_token`, `reset_expire`, `created`) VALUES (1,'admin','$2a$10$mzKU71G62evnGB2PvQA4k..Wf9jASk.c7a8zRMHh6qQVjYJ2r/g/K','admin@example.com',NULL,NULL,NOW());
2016-04-04 12:36:30 +00:00
SET UNIQUE_CHECKS=1;
SET FOREIGN_KEY_CHECKS=1;