00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 $installer = $this;
00036
00037
00038 $installer->startSetup();
00039 $installer->run("
00040 -- DROP TABLE IF EXISTS `{$installer->getTable('newsletter_problem')}`;
00041 CREATE TABLE `{$installer->getTable('newsletter_problem')}` (
00042 `problem_id` int(7) unsigned NOT NULL auto_increment,
00043 `subscriber_id` int(7) unsigned default NULL,
00044 `queue_id` int(7) unsigned NOT NULL default '0',
00045 `problem_error_code` int(3) unsigned default '0',
00046 `problem_error_text` varchar(200) default NULL,
00047 PRIMARY KEY (`problem_id`),
00048 KEY `FK_PROBLEM_SUBSCRIBER` (`subscriber_id`),
00049 KEY `FK_PROBLEM_QUEUE` (`queue_id`),
00050 CONSTRAINT `FK_PROBLEM_QUEUE` FOREIGN KEY (`queue_id`) REFERENCES `{$installer->getTable('newsletter_queue')}` (`queue_id`),
00051 CONSTRAINT `FK_PROBLEM_SUBSCRIBER` FOREIGN KEY (`subscriber_id`) REFERENCES `{$installer->getTable('newsletter_subscriber')}` (`subscriber_id`)
00052 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Newsletter problems';
00053
00054 -- DROP TABLE IF EXISTS `{$installer->getTable('newsletter_queue')}`;
00055 CREATE TABLE `{$installer->getTable('newsletter_queue')}` (
00056 `queue_id` int(7) unsigned NOT NULL auto_increment,
00057 `template_id` int(7) unsigned NOT NULL default '0',
00058 `queue_status` int(3) unsigned NOT NULL default '0',
00059 `queue_start_at` datetime default NULL,
00060 `queue_finish_at` datetime default NULL,
00061 PRIMARY KEY (`queue_id`),
00062 KEY `FK_QUEUE_TEMPLATE` (`template_id`),
00063 CONSTRAINT `FK_QUEUE_TEMPLATE` FOREIGN KEY (`template_id`) REFERENCES `{$installer->getTable('newsletter_template')}` (`template_id`) ON DELETE CASCADE
00064 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Newsletter queue';
00065
00066 -- DROP TABLE IF EXISTS `{$installer->getTable('newsletter_queue_link')}`;
00067 CREATE TABLE `{$installer->getTable('newsletter_queue_link')}` (
00068 `queue_link_id` int(9) unsigned NOT NULL auto_increment,
00069 `queue_id` int(7) unsigned NOT NULL default '0',
00070 `subscriber_id` int(7) unsigned NOT NULL default '0',
00071 `letter_sent_at` datetime default NULL,
00072 PRIMARY KEY (`queue_link_id`),
00073 KEY `FK_QUEUE_LINK_SUBSCRIBER` (`subscriber_id`),
00074 KEY `FK_QUEUE_LINK_QUEUE` (`queue_id`),
00075 CONSTRAINT `FK_QUEUE_LINK_QUEUE` FOREIGN KEY (`queue_id`) REFERENCES `{$installer->getTable('newsletter_queue')}` (`queue_id`) ON DELETE CASCADE,
00076 CONSTRAINT `FK_QUEUE_LINK_SUBSCRIBER` FOREIGN KEY (`subscriber_id`) REFERENCES `{$installer->getTable('newsletter_subscriber')}` (`subscriber_id`) ON DELETE CASCADE
00077 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Newsletter queue to subscriber link';
00078
00079 -- DROP TABLE IF EXISTS `{$installer->getTable('newsletter_queue_store_link')}`;
00080 CREATE TABLE `{$installer->getTable('newsletter_queue_store_link')}` (
00081 `queue_id` int(7) unsigned NOT NULL default '0',
00082 `store_id` smallint(5) unsigned NOT NULL default '0',
00083 PRIMARY KEY (`queue_id`,`store_id`),
00084 KEY `FK_NEWSLETTER_QUEUE_STORE_LINK_STORE` (`store_id`),
00085 CONSTRAINT `FK_NEWSLETTER_QUEUE_STORE_LINK_STORE` FOREIGN KEY (`store_id`) REFERENCES `{$installer->getTable('core_store')}` (`store_id`) ON DELETE CASCADE ON UPDATE CASCADE,
00086 CONSTRAINT `FK_LINK_QUEUE` FOREIGN KEY (`queue_id`) REFERENCES `{$installer->getTable('newsletter_queue')}` (`queue_id`) ON DELETE CASCADE
00087 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
00088
00089 -- DROP TABLE IF EXISTS `{$installer->getTable('newsletter_subscriber')}`;
00090 CREATE TABLE `{$installer->getTable('newsletter_subscriber')}` (
00091 `subscriber_id` int(7) unsigned NOT NULL auto_increment,
00092 `store_id` smallint(5) unsigned default '0',
00093 `change_status_at` datetime default NULL,
00094 `customer_id` int(11) unsigned NOT NULL default '0',
00095 `subscriber_email` varchar(150) character set latin1 collate latin1_general_ci NOT NULL default '',
00096 `subscriber_status` int(3) NOT NULL default '0',
00097 `subscriber_confirm_code` varchar(32) default 'NULL',
00098 PRIMARY KEY (`subscriber_id`),
00099 KEY `FK_SUBSCRIBER_CUSTOMER` (`customer_id`),
00100 KEY `FK_NEWSLETTER_SUBSCRIBER_STORE` (`store_id`),
00101 CONSTRAINT `FK_NEWSLETTER_SUBSCRIBER_STORE` FOREIGN KEY (`store_id`) REFERENCES `{$installer->getTable('core_store')}` (`store_id`) ON DELETE SET NULL ON UPDATE CASCADE
00102 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Newsletter subscribers';
00103
00104 -- DROP TABLE IF EXISTS `{$installer->getTable('newsletter_template')}`;
00105 CREATE TABLE `{$installer->getTable('newsletter_template')}` (
00106 `template_id` int(7) unsigned NOT NULL auto_increment,
00107 `template_code` varchar(150) default NULL,
00108 `template_text` text,
00109 `template_text_preprocessed` text,
00110 `template_type` int(3) unsigned default NULL,
00111 `template_subject` varchar(200) default NULL,
00112 `template_sender_name` varchar(200) default NULL,
00113 `template_sender_email` varchar(200) character set latin1 collate latin1_general_ci default NULL,
00114 `template_actual` tinyint(1) unsigned default '1',
00115 `added_at` datetime default NULL,
00116 `modified_at` datetime default NULL,
00117 PRIMARY KEY (`template_id`),
00118 KEY `template_actual` (`template_actual`),
00119 KEY `added_at` (`added_at`),
00120 KEY `modified_at` (`modified_at`)
00121 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Newsletter templates';
00122 ");
00123 $installer->endSetup();