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('customer_address_entity')}`;
00041 CREATE TABLE `{$installer->getTable('customer_address_entity')}` (
00042 `entity_id` int(10) unsigned NOT NULL auto_increment,
00043 `entity_type_id` smallint(8) unsigned NOT NULL default '0',
00044 `attribute_set_id` smallint(5) unsigned NOT NULL default '0',
00045 `increment_id` varchar(50) NOT NULL default '',
00046 `parent_id` int(10) unsigned default NULL,
00047 `created_at` datetime NOT NULL default '0000-00-00 00:00:00',
00048 `updated_at` datetime NOT NULL default '0000-00-00 00:00:00',
00049 `is_active` tinyint(1) unsigned NOT NULL default '1',
00050 PRIMARY KEY (`entity_id`),
00051 KEY `FK_CUSTOMER_ADDRESS_CUSTOMER_ID` (`parent_id`),
00052 CONSTRAINT `FK_CUSTOMER_ADDRESS_CUSTOMER_ID` FOREIGN KEY (`parent_id`) REFERENCES `{$installer->getTable('customer_entity')}` (`entity_id`) ON DELETE CASCADE ON UPDATE CASCADE
00053 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='Customer Address Entities';
00054
00055 -- DROP TABLE IF EXISTS `{$installer->getTable('customer_address_entity_datetime')}`;
00056 CREATE TABLE `{$installer->getTable('customer_address_entity_datetime')}` (
00057 `value_id` int(11) NOT NULL auto_increment,
00058 `entity_type_id` smallint(8) unsigned NOT NULL default '0',
00059 `attribute_id` smallint(5) unsigned NOT NULL default '0',
00060 `entity_id` int(10) unsigned NOT NULL default '0',
00061 `value` datetime NOT NULL default '0000-00-00 00:00:00',
00062 PRIMARY KEY (`value_id`),
00063 KEY `FK_CUSTOMER_ADDRESS_DATETIME_ENTITY_TYPE` (`entity_type_id`),
00064 KEY `FK_CUSTOMER_ADDRESS_DATETIME_ATTRIBUTE` (`attribute_id`),
00065 KEY `FK_CUSTOMER_ADDRESS_DATETIME_ENTITY` (`entity_id`),
00066 CONSTRAINT `FK_CUSTOMER_ADDRESS_DATETIME_ATTRIBUTE` FOREIGN KEY (`attribute_id`) REFERENCES `{$installer->getTable('eav_attribute')}` (`attribute_id`) ON DELETE CASCADE ON UPDATE CASCADE,
00067 CONSTRAINT `FK_CUSTOMER_ADDRESS_DATETIME_ENTITY` FOREIGN KEY (`entity_id`) REFERENCES `{$installer->getTable('customer_address_entity')}` (`entity_id`) ON DELETE CASCADE ON UPDATE CASCADE,
00068 CONSTRAINT `FK_CUSTOMER_ADDRESS_DATETIME_ENTITY_TYPE` FOREIGN KEY (`entity_type_id`) REFERENCES `{$installer->getTable('eav_entity_type')}` (`entity_type_id`) ON DELETE CASCADE ON UPDATE CASCADE
00069 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
00070
00071 -- DROP TABLE IF EXISTS `{$installer->getTable('customer_address_entity_decimal')}`;
00072 CREATE TABLE `{$installer->getTable('customer_address_entity_decimal')}` (
00073 `value_id` int(11) NOT NULL auto_increment,
00074 `entity_type_id` smallint(8) unsigned NOT NULL default '0',
00075 `attribute_id` smallint(5) unsigned NOT NULL default '0',
00076 `entity_id` int(10) unsigned NOT NULL default '0',
00077 `value` decimal(12,4) NOT NULL default '0.0000',
00078 PRIMARY KEY (`value_id`),
00079 KEY `FK_CUSTOMER_ADDRESS_DECIMAL_ENTITY_TYPE` (`entity_type_id`),
00080 KEY `FK_CUSTOMER_ADDRESS_DECIMAL_ATTRIBUTE` (`attribute_id`),
00081 KEY `FK_CUSTOMER_ADDRESS_DECIMAL_ENTITY` (`entity_id`),
00082 CONSTRAINT `FK_CUSTOMER_ADDRESS_DECIMAL_ATTRIBUTE` FOREIGN KEY (`attribute_id`) REFERENCES `{$installer->getTable('eav_attribute')}` (`attribute_id`) ON DELETE CASCADE ON UPDATE CASCADE,
00083 CONSTRAINT `FK_CUSTOMER_ADDRESS_DECIMAL_ENTITY` FOREIGN KEY (`entity_id`) REFERENCES `{$installer->getTable('customer_address_entity')}` (`entity_id`) ON DELETE CASCADE ON UPDATE CASCADE,
00084 CONSTRAINT `FK_CUSTOMER_ADDRESS_DECIMAL_ENTITY_TYPE` FOREIGN KEY (`entity_type_id`) REFERENCES `{$installer->getTable('eav_entity_type')}` (`entity_type_id`) ON DELETE CASCADE ON UPDATE CASCADE
00085 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
00086
00087 -- DROP TABLE IF EXISTS `{$installer->getTable('customer_address_entity_int')}`;
00088 CREATE TABLE `{$installer->getTable('customer_address_entity_int')}` (
00089 `value_id` int(11) NOT NULL auto_increment,
00090 `entity_type_id` smallint(8) unsigned NOT NULL default '0',
00091 `attribute_id` smallint(5) unsigned NOT NULL default '0',
00092 `entity_id` int(10) unsigned NOT NULL default '0',
00093 `value` int(11) NOT NULL default '0',
00094 PRIMARY KEY (`value_id`),
00095 KEY `FK_CUSTOMER_ADDRESS_INT_ENTITY_TYPE` (`entity_type_id`),
00096 KEY `FK_CUSTOMER_ADDRESS_INT_ATTRIBUTE` (`attribute_id`),
00097 KEY `FK_CUSTOMER_ADDRESS_INT_ENTITY` (`entity_id`),
00098 CONSTRAINT `FK_CUSTOMER_ADDRESS_INT_ATTRIBUTE` FOREIGN KEY (`attribute_id`) REFERENCES `{$installer->getTable('eav_attribute')}` (`attribute_id`) ON DELETE CASCADE ON UPDATE CASCADE,
00099 CONSTRAINT `FK_CUSTOMER_ADDRESS_INT_ENTITY` FOREIGN KEY (`entity_id`) REFERENCES `{$installer->getTable('customer_address_entity')}` (`entity_id`) ON DELETE CASCADE ON UPDATE CASCADE,
00100 CONSTRAINT `FK_CUSTOMER_ADDRESS_INT_ENTITY_TYPE` FOREIGN KEY (`entity_type_id`) REFERENCES `{$installer->getTable('eav_entity_type')}` (`entity_type_id`) ON DELETE CASCADE ON UPDATE CASCADE
00101 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
00102
00103 -- DROP TABLE IF EXISTS `{$installer->getTable('customer_address_entity_text')}`;
00104 CREATE TABLE `{$installer->getTable('customer_address_entity_text')}` (
00105 `value_id` int(11) NOT NULL auto_increment,
00106 `entity_type_id` smallint(8) unsigned NOT NULL default '0',
00107 `attribute_id` smallint(5) unsigned NOT NULL default '0',
00108 `entity_id` int(10) unsigned NOT NULL default '0',
00109 `value` text NOT NULL,
00110 PRIMARY KEY (`value_id`),
00111 KEY `FK_CUSTOMER_ADDRESS_TEXT_ENTITY_TYPE` (`entity_type_id`),
00112 KEY `FK_CUSTOMER_ADDRESS_TEXT_ATTRIBUTE` (`attribute_id`),
00113 KEY `FK_CUSTOMER_ADDRESS_TEXT_ENTITY` (`entity_id`),
00114 CONSTRAINT `FK_CUSTOMER_ADDRESS_TEXT_ATTRIBUTE` FOREIGN KEY (`attribute_id`) REFERENCES `{$installer->getTable('eav_attribute')}` (`attribute_id`) ON DELETE CASCADE ON UPDATE CASCADE,
00115 CONSTRAINT `FK_CUSTOMER_ADDRESS_TEXT_ENTITY` FOREIGN KEY (`entity_id`) REFERENCES `{$installer->getTable('customer_address_entity')}` (`entity_id`) ON DELETE CASCADE ON UPDATE CASCADE,
00116 CONSTRAINT `FK_CUSTOMER_ADDRESS_TEXT_ENTITY_TYPE` FOREIGN KEY (`entity_type_id`) REFERENCES `{$installer->getTable('eav_entity_type')}` (`entity_type_id`) ON DELETE CASCADE ON UPDATE CASCADE
00117 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
00118
00119 -- DROP TABLE IF EXISTS `{$installer->getTable('customer_address_entity_varchar')}`;
00120 CREATE TABLE `{$installer->getTable('customer_address_entity_varchar')}` (
00121 `value_id` int(11) NOT NULL auto_increment,
00122 `entity_type_id` smallint(8) unsigned NOT NULL default '0',
00123 `attribute_id` smallint(5) unsigned NOT NULL default '0',
00124 `entity_id` int(10) unsigned NOT NULL default '0',
00125 `value` varchar(255) NOT NULL default '',
00126 PRIMARY KEY (`value_id`),
00127 KEY `FK_CUSTOMER_ADDRESS_VARCHAR_ENTITY_TYPE` (`entity_type_id`),
00128 KEY `FK_CUSTOMER_ADDRESS_VARCHAR_ATTRIBUTE` (`attribute_id`),
00129 KEY `FK_CUSTOMER_ADDRESS_VARCHAR_ENTITY` (`entity_id`),
00130 CONSTRAINT `FK_CUSTOMER_ADDRESS_VARCHAR_ATTRIBUTE` FOREIGN KEY (`attribute_id`) REFERENCES `{$installer->getTable('eav_attribute')}` (`attribute_id`) ON DELETE CASCADE ON UPDATE CASCADE,
00131 CONSTRAINT `FK_CUSTOMER_ADDRESS_VARCHAR_ENTITY` FOREIGN KEY (`entity_id`) REFERENCES `{$installer->getTable('customer_address_entity')}` (`entity_id`) ON DELETE CASCADE ON UPDATE CASCADE,
00132 CONSTRAINT `FK_CUSTOMER_ADDRESS_VARCHAR_ENTITY_TYPE` FOREIGN KEY (`entity_type_id`) REFERENCES `{$installer->getTable('eav_entity_type')}` (`entity_type_id`) ON DELETE CASCADE ON UPDATE CASCADE
00133 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
00134
00135 -- DROP TABLE IF EXISTS `{$installer->getTable('customer_entity')}`;
00136 CREATE TABLE `{$installer->getTable('customer_entity')}` (
00137 `entity_id` int(10) unsigned NOT NULL auto_increment,
00138 `entity_type_id` smallint(8) unsigned NOT NULL default '0',
00139 `attribute_set_id` smallint(5) unsigned NOT NULL default '0',
00140 `website_id` smallint(5) unsigned default NULL,
00141 `email` varchar(255) NOT NULL default '',
00142 `group_id` smallint(3) unsigned NOT NULL default '0',
00143 `increment_id` varchar(50) NOT NULL default '',
00144 `store_id` smallint(5) unsigned default '0',
00145 `created_at` datetime NOT NULL default '0000-00-00 00:00:00',
00146 `updated_at` datetime NOT NULL default '0000-00-00 00:00:00',
00147 `is_active` tinyint(1) unsigned NOT NULL default '1',
00148 PRIMARY KEY (`entity_id`),
00149 KEY `FK_CUSTOMER_ENTITY_STORE` (`store_id`),
00150 KEY `IDX_ENTITY_TYPE` (`entity_type_id`),
00151 KEY `IDX_AUTH` (`email`,`website_id`),
00152 KEY `FK_CUSTOMER_WEBSITE` (`website_id`),
00153 CONSTRAINT `FK_CUSTOMER_ENTITY_STORE` FOREIGN KEY (`store_id`) REFERENCES `{$installer->getTable('core_store')}` (`store_id`) ON DELETE SET NULL ON UPDATE CASCADE,
00154 CONSTRAINT `FK_CUSTOMER_WEBSITE` FOREIGN KEY (`website_id`) REFERENCES `{$installer->getTable('core_website')}` (`website_id`) ON DELETE SET NULL ON UPDATE CASCADE
00155 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='Customer Entityies';
00156
00157 -- DROP TABLE IF EXISTS `{$installer->getTable('customer_entity_datetime')}`;
00158 CREATE TABLE `{$installer->getTable('customer_entity_datetime')}` (
00159 `value_id` int(11) NOT NULL auto_increment,
00160 `entity_type_id` smallint(8) unsigned NOT NULL default '0',
00161 `attribute_id` smallint(5) unsigned NOT NULL default '0',
00162 `entity_id` int(10) unsigned NOT NULL default '0',
00163 `value` datetime NOT NULL default '0000-00-00 00:00:00',
00164 PRIMARY KEY (`value_id`),
00165 KEY `FK_CUSTOMER_DATETIME_ENTITY_TYPE` (`entity_type_id`),
00166 KEY `FK_CUSTOMER_DATETIME_ATTRIBUTE` (`attribute_id`),
00167 KEY `FK_CUSTOMER_DATETIME_ENTITY` (`entity_id`),
00168 CONSTRAINT `FK_CUSTOMER_DATETIME_ATTRIBUTE` FOREIGN KEY (`attribute_id`) REFERENCES `{$installer->getTable('eav_attribute')}` (`attribute_id`) ON DELETE CASCADE ON UPDATE CASCADE,
00169 CONSTRAINT `FK_CUSTOMER_DATETIME_ENTITY` FOREIGN KEY (`entity_id`) REFERENCES `{$installer->getTable('customer_entity')}` (`entity_id`) ON DELETE CASCADE ON UPDATE CASCADE,
00170 CONSTRAINT `FK_CUSTOMER_DATETIME_ENTITY_TYPE` FOREIGN KEY (`entity_type_id`) REFERENCES `{$installer->getTable('eav_entity_type')}` (`entity_type_id`) ON DELETE CASCADE ON UPDATE CASCADE
00171 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
00172
00173 -- DROP TABLE IF EXISTS `{$installer->getTable('customer_entity_decimal')}`;
00174 CREATE TABLE `{$installer->getTable('customer_entity_decimal')}` (
00175 `value_id` int(11) NOT NULL auto_increment,
00176 `entity_type_id` smallint(8) unsigned NOT NULL default '0',
00177 `attribute_id` smallint(5) unsigned NOT NULL default '0',
00178 `entity_id` int(10) unsigned NOT NULL default '0',
00179 `value` decimal(12,4) NOT NULL default '0.0000',
00180 PRIMARY KEY (`value_id`),
00181 KEY `FK_CUSTOMER_DECIMAL_ENTITY_TYPE` (`entity_type_id`),
00182 KEY `FK_CUSTOMER_DECIMAL_ATTRIBUTE` (`attribute_id`),
00183 KEY `FK_CUSTOMER_DECIMAL_ENTITY` (`entity_id`),
00184 CONSTRAINT `FK_CUSTOMER_DECIMAL_ATTRIBUTE` FOREIGN KEY (`attribute_id`) REFERENCES `{$installer->getTable('eav_attribute')}` (`attribute_id`) ON DELETE CASCADE ON UPDATE CASCADE,
00185 CONSTRAINT `FK_CUSTOMER_DECIMAL_ENTITY` FOREIGN KEY (`entity_id`) REFERENCES `{$installer->getTable('customer_entity')}` (`entity_id`) ON DELETE CASCADE ON UPDATE CASCADE,
00186 CONSTRAINT `FK_CUSTOMER_DECIMAL_ENTITY_TYPE` FOREIGN KEY (`entity_type_id`) REFERENCES `{$installer->getTable('eav_entity_type')}` (`entity_type_id`) ON DELETE CASCADE ON UPDATE CASCADE
00187 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
00188
00189 -- DROP TABLE IF EXISTS `{$installer->getTable('customer_entity_int')}`;
00190 CREATE TABLE `{$installer->getTable('customer_entity_int')}` (
00191 `value_id` int(11) NOT NULL auto_increment,
00192 `entity_type_id` smallint(8) unsigned NOT NULL default '0',
00193 `attribute_id` smallint(5) unsigned NOT NULL default '0',
00194 `entity_id` int(10) unsigned NOT NULL default '0',
00195 `value` int(11) NOT NULL default '0',
00196 PRIMARY KEY (`value_id`),
00197 KEY `FK_CUSTOMER_INT_ENTITY_TYPE` (`entity_type_id`),
00198 KEY `FK_CUSTOMER_INT_ATTRIBUTE` (`attribute_id`),
00199 KEY `FK_CUSTOMER_INT_ENTITY` (`entity_id`),
00200 CONSTRAINT `FK_CUSTOMER_INT_ATTRIBUTE` FOREIGN KEY (`attribute_id`) REFERENCES `{$installer->getTable('eav_attribute')}` (`attribute_id`) ON DELETE CASCADE ON UPDATE CASCADE,
00201 CONSTRAINT `FK_CUSTOMER_INT_ENTITY` FOREIGN KEY (`entity_id`) REFERENCES `{$installer->getTable('customer_entity')}` (`entity_id`) ON DELETE CASCADE ON UPDATE CASCADE,
00202 CONSTRAINT `FK_CUSTOMER_INT_ENTITY_TYPE` FOREIGN KEY (`entity_type_id`) REFERENCES `{$installer->getTable('eav_entity_type')}` (`entity_type_id`) ON DELETE CASCADE ON UPDATE CASCADE
00203 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
00204
00205 -- DROP TABLE IF EXISTS `{$installer->getTable('customer_entity_text')}`;
00206 CREATE TABLE `{$installer->getTable('customer_entity_text')}` (
00207 `value_id` int(11) NOT NULL auto_increment,
00208 `entity_type_id` smallint(8) unsigned NOT NULL default '0',
00209 `attribute_id` smallint(5) unsigned NOT NULL default '0',
00210 `entity_id` int(10) unsigned NOT NULL default '0',
00211 `value` text NOT NULL,
00212 PRIMARY KEY (`value_id`),
00213 KEY `FK_CUSTOMER_TEXT_ENTITY_TYPE` (`entity_type_id`),
00214 KEY `FK_CUSTOMER_TEXT_ATTRIBUTE` (`attribute_id`),
00215 KEY `FK_CUSTOMER_TEXT_ENTITY` (`entity_id`),
00216 CONSTRAINT `FK_CUSTOMER_TEXT_ATTRIBUTE` FOREIGN KEY (`attribute_id`) REFERENCES `{$installer->getTable('eav_attribute')}` (`attribute_id`) ON DELETE CASCADE ON UPDATE CASCADE,
00217 CONSTRAINT `FK_CUSTOMER_TEXT_ENTITY` FOREIGN KEY (`entity_id`) REFERENCES `{$installer->getTable('customer_entity')}` (`entity_id`) ON DELETE CASCADE ON UPDATE CASCADE,
00218 CONSTRAINT `FK_CUSTOMER_TEXT_ENTITY_TYPE` FOREIGN KEY (`entity_type_id`) REFERENCES `{$installer->getTable('eav_entity_type')}` (`entity_type_id`) ON DELETE CASCADE ON UPDATE CASCADE
00219 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
00220
00221 -- DROP TABLE IF EXISTS `{$installer->getTable('customer_entity_varchar')}`;
00222 CREATE TABLE `{$installer->getTable('customer_entity_varchar')}` (
00223 `value_id` int(11) NOT NULL auto_increment,
00224 `entity_type_id` smallint(8) unsigned NOT NULL default '0',
00225 `attribute_id` smallint(5) unsigned NOT NULL default '0',
00226 `entity_id` int(10) unsigned NOT NULL default '0',
00227 `value` varchar(255) NOT NULL default '',
00228 PRIMARY KEY (`value_id`),
00229 KEY `FK_CUSTOMER_VARCHAR_ENTITY_TYPE` (`entity_type_id`),
00230 KEY `FK_CUSTOMER_VARCHAR_ATTRIBUTE` (`attribute_id`),
00231 KEY `FK_CUSTOMER_VARCHAR_ENTITY` (`entity_id`),
00232 CONSTRAINT `FK_CUSTOMER_VARCHAR_ATTRIBUTE` FOREIGN KEY (`attribute_id`) REFERENCES `{$installer->getTable('eav_attribute')}` (`attribute_id`) ON DELETE CASCADE ON UPDATE CASCADE,
00233 CONSTRAINT `FK_CUSTOMER_VARCHAR_ENTITY` FOREIGN KEY (`entity_id`) REFERENCES `{$installer->getTable('customer_entity')}` (`entity_id`) ON DELETE CASCADE ON UPDATE CASCADE,
00234 CONSTRAINT `FK_CUSTOMER_VARCHAR_ENTITY_TYPE` FOREIGN KEY (`entity_type_id`) REFERENCES `{$installer->getTable('eav_entity_type')}` (`entity_type_id`) ON DELETE CASCADE ON UPDATE CASCADE
00235 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
00236
00237 -- DROP TABLE IF EXISTS `{$installer->getTable('customer_group')}`;
00238 CREATE TABLE `{$installer->getTable('customer_group')}` (
00239 `customer_group_id` smallint(3) unsigned NOT NULL auto_increment,
00240 `customer_group_code` varchar(32) NOT NULL default '',
00241 `tax_class_id` int(10) unsigned NOT NULL default '0',
00242 PRIMARY KEY (`customer_group_id`)
00243 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Customer groups';
00244
00245 INSERT INTO `{$installer->getTable('customer_group')}` VALUES(0, 'NOT LOGGED IN', 3), (1, 'General', 3), (2, 'Wholesale', 3), (3, 'Retailer', 3);
00246 ");
00247 $installer->endSetup();
00248 $installer->installEntities();