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 $installer = $this;
00028
00029
00030 $installer->startSetup();
00031
00032 $installer->run("
00033
00034 -- DROP TABLE IF EXISTS {$this->getTable('eav_attribute')};
00035 CREATE TABLE {$this->getTable('eav_attribute')} (
00036 `attribute_id` smallint(5) unsigned NOT NULL auto_increment,
00037 `entity_type_id` smallint(5) unsigned NOT NULL default '0',
00038 `attribute_code` varchar(255) NOT NULL default '',
00039 `attribute_model` varchar(255) default NULL,
00040 `backend_model` varchar(255) default NULL,
00041 `backend_type` enum('static','datetime','decimal','int','text','varchar') NOT NULL default 'static',
00042 `backend_table` varchar(255) default NULL,
00043 `frontend_model` varchar(255) default NULL,
00044 `frontend_input` varchar(50) default NULL,
00045 `frontend_input_renderer` varchar(255) default NULL,
00046 `frontend_label` varchar(255) default NULL,
00047 `frontend_class` varchar(255) default NULL,
00048 `source_model` varchar(255) default NULL,
00049 `is_global` tinyint(1) unsigned NOT NULL default '1',
00050 `is_visible` tinyint(1) unsigned NOT NULL default '1',
00051 `is_required` tinyint(1) unsigned NOT NULL default '0',
00052 `is_user_defined` tinyint(1) unsigned NOT NULL default '0',
00053 `default_value` text,
00054 `is_searchable` tinyint(1) unsigned NOT NULL default '0',
00055 `is_filterable` tinyint(1) unsigned NOT NULL default '0',
00056 `is_comparable` tinyint(1) unsigned NOT NULL default '0',
00057 `is_visible_on_front` tinyint(1) unsigned NOT NULL default '0',
00058 `is_unique` tinyint(1) unsigned NOT NULL default '0',
00059 `apply_to` tinyint(3) unsigned NOT NULL default '0',
00060 `is_used_for_price_rules` tinyint(1) unsigned NOT NULL default '0',
00061 `is_filterable_in_search` tinyint(1) unsigned NOT NULL default '0',
00062 `use_in_super_product` tinyint(1) unsigned NOT NULL default '1',
00063 `used_in_product_listing` tinyint(1) unsigned NOT NULL default '0',
00064 `used_for_sort_by` tinyint(1) unsigned NOT NULL default '0',
00065 PRIMARY KEY (`attribute_id`),
00066 UNIQUE KEY `entity_type_id` (`entity_type_id`,`attribute_code`),
00067 KEY `IDX_USED_FOR_SORT_BY` (`entity_type_id`,`used_for_sort_by`),
00068 KEY `IDX_USED_IN_PRODUCT_LISTING` (`entity_type_id`,`used_in_product_listing`),
00069 CONSTRAINT `FK_eav_attribute` FOREIGN KEY (`entity_type_id`) REFERENCES `{$this->getTable('eav_entity_type')}` (`entity_type_id`) ON DELETE CASCADE ON UPDATE CASCADE
00070 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
00071
00072 -- DROP TABLE IF EXISTS {$this->getTable('eav_attribute_group')};
00073 CREATE TABLE {$this->getTable('eav_attribute_group')} (
00074 `attribute_group_id` smallint(5) unsigned NOT NULL auto_increment,
00075 `attribute_set_id` smallint(5) unsigned NOT NULL default '0',
00076 `attribute_group_name` varchar(255) character set latin1 NOT NULL default '',
00077 `sort_order` smallint(6) NOT NULL default '0',
00078 PRIMARY KEY (`attribute_group_id`),
00079 UNIQUE KEY `attribute_set_id` (`attribute_set_id`,`attribute_group_name`),
00080 KEY `attribute_set_id_2` (`attribute_set_id`,`sort_order`),
00081 CONSTRAINT `FK_eav_attribute_group` FOREIGN KEY (`attribute_set_id`) REFERENCES `{$this->getTable('eav_attribute_set')}` (`attribute_set_id`) ON DELETE CASCADE ON UPDATE CASCADE
00082 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
00083
00084 -- DROP TABLE IF EXISTS {$this->getTable('eav_attribute_option')};
00085 CREATE TABLE {$this->getTable('eav_attribute_option')} (
00086 `option_id` int(10) unsigned NOT NULL auto_increment,
00087 `attribute_id` smallint(5) unsigned NOT NULL default '0',
00088 `sort_order` smallint(5) unsigned NOT NULL default '0',
00089 PRIMARY KEY (`option_id`),
00090 KEY `FK_ATTRIBUTE_OPTION_ATTRIBUTE` (`attribute_id`),
00091 CONSTRAINT `FK_ATTRIBUTE_OPTION_ATTRIBUTE` FOREIGN KEY (`attribute_id`) REFERENCES `{$this->getTable('eav_attribute')}` (`attribute_id`) ON DELETE CASCADE ON UPDATE CASCADE
00092 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Attributes option (for source model)';
00093
00094 -- DROP TABLE IF EXISTS {$this->getTable('eav_attribute_option_value')};
00095 CREATE TABLE {$this->getTable('eav_attribute_option_value')} (
00096 `value_id` int(10) unsigned NOT NULL auto_increment,
00097 `option_id` int(10) unsigned NOT NULL default '0',
00098 `store_id` smallint(5) unsigned NOT NULL default '0',
00099 `value` varchar(255) NOT NULL default '',
00100 PRIMARY KEY (`value_id`),
00101 KEY `FK_ATTRIBUTE_OPTION_VALUE_OPTION` (`option_id`),
00102 KEY `FK_ATTRIBUTE_OPTION_VALUE_STORE` (`store_id`),
00103 CONSTRAINT `FK_ATTRIBUTE_OPTION_VALUE_OPTION` FOREIGN KEY (`option_id`) REFERENCES `{$this->getTable('eav_attribute_option')}` (`option_id`) ON DELETE CASCADE ON UPDATE CASCADE,
00104 CONSTRAINT `FK_ATTRIBUTE_OPTION_VALUE_STORE` FOREIGN KEY (`store_id`) REFERENCES `{$this->getTable('core_store')}` (`store_id`) ON DELETE CASCADE ON UPDATE CASCADE
00105 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Attribute option values per store';
00106
00107 -- DROP TABLE IF EXISTS {$this->getTable('eav_attribute_set')};
00108 CREATE TABLE {$this->getTable('eav_attribute_set')} (
00109 `attribute_set_id` smallint(5) unsigned NOT NULL auto_increment,
00110 `entity_type_id` smallint(5) unsigned NOT NULL default '0',
00111 `attribute_set_name` varchar(255) character set utf8 collate utf8_swedish_ci NOT NULL default '',
00112 `sort_order` smallint(6) NOT NULL default '0',
00113 PRIMARY KEY (`attribute_set_id`),
00114 UNIQUE KEY `entity_type_id` (`entity_type_id`,`attribute_set_name`),
00115 KEY `entity_type_id_2` (`entity_type_id`,`sort_order`),
00116 CONSTRAINT `FK_eav_attribute_set` FOREIGN KEY (`entity_type_id`) REFERENCES `{$this->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 {$this->getTable('eav_entity')};
00120 CREATE TABLE {$this->getTable('eav_entity')} (
00121 `entity_id` int(10) unsigned NOT NULL auto_increment,
00122 `entity_type_id` smallint(8) unsigned NOT NULL default '0',
00123 `attribute_set_id` smallint(5) unsigned NOT NULL default '0',
00124 `increment_id` varchar(50) NOT NULL default '',
00125 `parent_id` int(11) unsigned NOT NULL default '0',
00126 `store_id` smallint(5) unsigned NOT NULL default '0',
00127 `created_at` datetime NOT NULL default '0000-00-00 00:00:00',
00128 `updated_at` datetime NOT NULL default '0000-00-00 00:00:00',
00129 `is_active` tinyint(1) unsigned NOT NULL default '1',
00130 PRIMARY KEY (`entity_id`),
00131 KEY `FK_ENTITY_ENTITY_TYPE` (`entity_type_id`),
00132 KEY `FK_ENTITY_STORE` (`store_id`),
00133 CONSTRAINT `FK_eav_entity` FOREIGN KEY (`entity_type_id`) REFERENCES `{$this->getTable('eav_entity_type')}` (`entity_type_id`) ON DELETE CASCADE ON UPDATE CASCADE,
00134 CONSTRAINT `FK_eav_entity_store` FOREIGN KEY (`store_id`) REFERENCES `{$this->getTable('core_store')}` (`store_id`) ON DELETE CASCADE ON UPDATE CASCADE
00135 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Entityies';
00136
00137 -- DROP TABLE IF EXISTS {$this->getTable('eav_entity_attribute')};
00138 CREATE TABLE {$this->getTable('eav_entity_attribute')} (
00139 `entity_attribute_id` int(10) unsigned NOT NULL auto_increment,
00140 `entity_type_id` smallint(5) unsigned NOT NULL default '0',
00141 `attribute_set_id` smallint(5) unsigned NOT NULL default '0',
00142 `attribute_group_id` smallint(5) unsigned NOT NULL default '0',
00143 `attribute_id` smallint(5) unsigned NOT NULL default '0',
00144 `sort_order` smallint(6) NOT NULL default '0',
00145 PRIMARY KEY (`entity_attribute_id`),
00146 UNIQUE KEY `attribute_set_id_2` (`attribute_set_id`,`attribute_id`),
00147 UNIQUE KEY `attribute_group_id` (`attribute_group_id`,`attribute_id`),
00148 KEY `attribute_set_id_3` (`attribute_set_id`,`sort_order`),
00149 KEY `FK_EAV_ENTITY_ATTRIVUTE_ATTRIBUTE` (`attribute_id`),
00150 CONSTRAINT `FK_EAV_ENTITY_ATTRIBUTE_ATTRIBUTE` FOREIGN KEY (`attribute_id`) REFERENCES `{$this->getTable('eav_attribute')}` (`attribute_id`) ON DELETE CASCADE ON UPDATE CASCADE,
00151 CONSTRAINT `FK_EAV_ENTITY_ATTRIBUTE_GROUP` FOREIGN KEY (`attribute_group_id`) REFERENCES `{$this->getTable('eav_attribute_group')}` (`attribute_group_id`) ON DELETE CASCADE ON UPDATE CASCADE
00152 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
00153
00154 -- DROP TABLE IF EXISTS {$this->getTable('eav_entity_datetime')};
00155 CREATE TABLE {$this->getTable('eav_entity_datetime')} (
00156 `value_id` int(11) NOT NULL auto_increment,
00157 `entity_type_id` smallint(5) unsigned NOT NULL default '0',
00158 `attribute_id` smallint(5) unsigned NOT NULL default '0',
00159 `store_id` smallint(5) unsigned NOT NULL default '0',
00160 `entity_id` int(10) unsigned NOT NULL default '0',
00161 `value` datetime NOT NULL default '0000-00-00 00:00:00',
00162 PRIMARY KEY (`value_id`),
00163 KEY `FK_ATTRIBUTE_DATETIME_ENTITY_TYPE` (`entity_type_id`),
00164 KEY `FK_ATTRIBUTE_DATETIME_ATTRIBUTE` (`attribute_id`),
00165 KEY `FK_ATTRIBUTE_DATETIME_STORE` (`store_id`),
00166 KEY `FK_ATTRIBUTE_DATETIME_ENTITY` (`entity_id`),
00167 KEY `value_by_attribute` (`attribute_id`,`value`),
00168 KEY `value_by_entity_type` (`entity_type_id`,`value`),
00169 CONSTRAINT `FK_EAV_ENTITY_DATETIME_ENTITY` FOREIGN KEY (`entity_id`) REFERENCES `{$this->getTable('eav_entity')}` (`entity_id`) ON DELETE CASCADE ON UPDATE CASCADE,
00170 CONSTRAINT `FK_EAV_ENTITY_DATETIME_ENTITY_TYPE` FOREIGN KEY (`entity_type_id`) REFERENCES `{$this->getTable('eav_entity_type')}` (`entity_type_id`) ON DELETE CASCADE ON UPDATE CASCADE,
00171 CONSTRAINT `FK_EAV_ENTITY_DATETIME_STORE` FOREIGN KEY (`store_id`) REFERENCES `{$this->getTable('core_store')}` (`store_id`) ON DELETE CASCADE ON UPDATE CASCADE
00172 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Datetime values of attributes';
00173
00174 -- DROP TABLE IF EXISTS {$this->getTable('eav_entity_decimal')};
00175 CREATE TABLE {$this->getTable('eav_entity_decimal')} (
00176 `value_id` int(11) NOT NULL auto_increment,
00177 `entity_type_id` smallint(5) unsigned NOT NULL default '0',
00178 `attribute_id` smallint(5) unsigned NOT NULL default '0',
00179 `store_id` smallint(5) unsigned NOT NULL default '0',
00180 `entity_id` int(10) unsigned NOT NULL default '0',
00181 `value` decimal(12,4) NOT NULL default '0.0000',
00182 PRIMARY KEY (`value_id`),
00183 KEY `FK_ATTRIBUTE_DECIMAL_ENTITY_TYPE` (`entity_type_id`),
00184 KEY `FK_ATTRIBUTE_DECIMAL_ATTRIBUTE` (`attribute_id`),
00185 KEY `FK_ATTRIBUTE_DECIMAL_STORE` (`store_id`),
00186 KEY `FK_ATTRIBUTE_DECIMAL_ENTITY` (`entity_id`),
00187 KEY `value_by_attribute` (`attribute_id`,`value`),
00188 KEY `value_by_entity_type` (`entity_type_id`,`value`),
00189 CONSTRAINT `FK_EAV_ENTITY_DECIMAL_ENTITY` FOREIGN KEY (`entity_id`) REFERENCES `{$this->getTable('eav_entity')}` (`entity_id`) ON DELETE CASCADE ON UPDATE CASCADE,
00190 CONSTRAINT `FK_EAV_ENTITY_DECIMAL_ENTITY_TYPE` FOREIGN KEY (`entity_type_id`) REFERENCES `{$this->getTable('eav_entity_type')}` (`entity_type_id`) ON DELETE CASCADE ON UPDATE CASCADE,
00191 CONSTRAINT `FK_EAV_ENTITY_DECIMAL_STORE` FOREIGN KEY (`store_id`) REFERENCES `{$this->getTable('core_store')}` (`store_id`) ON DELETE CASCADE ON UPDATE CASCADE
00192 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Decimal values of attributes';
00193
00194 -- DROP TABLE IF EXISTS {$this->getTable('eav_entity_int')};
00195 CREATE TABLE {$this->getTable('eav_entity_int')} (
00196 `value_id` int(11) NOT NULL auto_increment,
00197 `entity_type_id` smallint(5) unsigned NOT NULL default '0',
00198 `attribute_id` smallint(5) unsigned NOT NULL default '0',
00199 `store_id` smallint(5) unsigned NOT NULL default '0',
00200 `entity_id` int(10) unsigned NOT NULL default '0',
00201 `value` int(11) NOT NULL default '0',
00202 PRIMARY KEY (`value_id`),
00203 KEY `FK_ATTRIBUTE_INT_ENTITY_TYPE` (`entity_type_id`),
00204 KEY `FK_ATTRIBUTE_INT_ATTRIBUTE` (`attribute_id`),
00205 KEY `FK_ATTRIBUTE_INT_STORE` (`store_id`),
00206 KEY `FK_ATTRIBUTE_INT_ENTITY` (`entity_id`),
00207 KEY `value_by_attribute` (`attribute_id`,`value`),
00208 KEY `value_by_entity_type` (`entity_type_id`,`value`),
00209 CONSTRAINT `FK_EAV_ENTITY_INT_ENTITY` FOREIGN KEY (`entity_id`) REFERENCES `{$this->getTable('eav_entity')}` (`entity_id`) ON DELETE CASCADE ON UPDATE CASCADE,
00210 CONSTRAINT `FK_EAV_ENTITY_INT_ENTITY_TYPE` FOREIGN KEY (`entity_type_id`) REFERENCES `{$this->getTable('eav_entity_type')}` (`entity_type_id`) ON DELETE CASCADE ON UPDATE CASCADE,
00211 CONSTRAINT `FK_EAV_ENTITY_INT_STORE` FOREIGN KEY (`store_id`) REFERENCES `{$this->getTable('core_store')}` (`store_id`) ON DELETE CASCADE ON UPDATE CASCADE
00212 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Integer values of attributes';
00213
00214 -- DROP TABLE IF EXISTS {$this->getTable('eav_entity_store')};
00215 CREATE TABLE {$this->getTable('eav_entity_store')} (
00216 `entity_store_id` int(10) unsigned NOT NULL auto_increment,
00217 `entity_type_id` smallint(5) unsigned NOT NULL default '0',
00218 `store_id` smallint(5) unsigned NOT NULL default '0',
00219 `increment_prefix` varchar(20) NOT NULL default '',
00220 `increment_last_id` varchar(50) NOT NULL default '',
00221 PRIMARY KEY (`entity_store_id`),
00222 KEY `FK_eav_entity_store_entity_type` (`entity_type_id`),
00223 KEY `FK_eav_entity_store_store` (`store_id`),
00224 CONSTRAINT `FK_eav_entity_store_entity_type` FOREIGN KEY (`entity_type_id`) REFERENCES `{$this->getTable('eav_entity_type')}` (`entity_type_id`) ON DELETE CASCADE ON UPDATE CASCADE,
00225 CONSTRAINT `FK_eav_entity_store_store` FOREIGN KEY (`store_id`) REFERENCES `{$this->getTable('core_store')}` (`store_id`) ON DELETE CASCADE ON UPDATE CASCADE
00226 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
00227
00228 -- DROP TABLE IF EXISTS {$this->getTable('eav_entity_text')};
00229 CREATE TABLE {$this->getTable('eav_entity_text')} (
00230 `value_id` int(11) NOT NULL auto_increment,
00231 `entity_type_id` smallint(5) unsigned NOT NULL default '0',
00232 `attribute_id` smallint(5) unsigned NOT NULL default '0',
00233 `store_id` smallint(5) unsigned NOT NULL default '0',
00234 `entity_id` int(10) unsigned NOT NULL default '0',
00235 `value` text NOT NULL,
00236 PRIMARY KEY (`value_id`),
00237 KEY `FK_ATTRIBUTE_TEXT_ENTITY_TYPE` (`entity_type_id`),
00238 KEY `FK_ATTRIBUTE_TEXT_ATTRIBUTE` (`attribute_id`),
00239 KEY `FK_ATTRIBUTE_TEXT_STORE` (`store_id`),
00240 KEY `FK_ATTRIBUTE_TEXT_ENTITY` (`entity_id`),
00241 CONSTRAINT `FK_EAV_ENTITY_TEXT_ENTITY` FOREIGN KEY (`entity_id`) REFERENCES `{$this->getTable('eav_entity')}` (`entity_id`) ON DELETE CASCADE ON UPDATE CASCADE,
00242 CONSTRAINT `FK_EAV_ENTITY_TEXT_ENTITY_TYPE` FOREIGN KEY (`entity_type_id`) REFERENCES `{$this->getTable('eav_entity_type')}` (`entity_type_id`) ON DELETE CASCADE ON UPDATE CASCADE,
00243 CONSTRAINT `FK_EAV_ENTITY_TEXT_STORE` FOREIGN KEY (`store_id`) REFERENCES `{$this->getTable('core_store')}` (`store_id`) ON DELETE CASCADE ON UPDATE CASCADE
00244 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Text values of attributes';
00245
00246 -- DROP TABLE IF EXISTS {$this->getTable('eav_entity_type')};
00247 CREATE TABLE {$this->getTable('eav_entity_type')} (
00248 `entity_type_id` smallint(5) unsigned NOT NULL auto_increment,
00249 `entity_type_code` varchar(50) NOT NULL default '',
00250 `entity_table` varchar(255) NOT NULL default '',
00251 `value_table_prefix` varchar(255) NOT NULL default '',
00252 `entity_id_field` varchar(255) NOT NULL default '',
00253 `is_data_sharing` tinyint(4) unsigned NOT NULL default '1',
00254 `data_sharing_key` varchar(100) default 'default',
00255 `default_attribute_set_id` smallint(5) unsigned NOT NULL default '0',
00256 `increment_model` varchar(255) NOT NULL default '',
00257 `increment_per_store` tinyint(1) unsigned NOT NULL default '0',
00258 `increment_pad_length` tinyint(8) unsigned NOT NULL default '8',
00259 `increment_pad_char` char(1) NOT NULL default '0',
00260 PRIMARY KEY (`entity_type_id`),
00261 KEY `entity_name` (`entity_type_code`)
00262 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
00263
00264 -- DROP TABLE IF EXISTS {$this->getTable('eav_entity_varchar')};
00265 CREATE TABLE {$this->getTable('eav_entity_varchar')} (
00266 `value_id` int(11) NOT NULL auto_increment,
00267 `entity_type_id` smallint(5) unsigned NOT NULL default '0',
00268 `attribute_id` smallint(5) unsigned NOT NULL default '0',
00269 `store_id` smallint(5) unsigned NOT NULL default '0',
00270 `entity_id` int(10) unsigned NOT NULL default '0',
00271 `value` varchar(255) NOT NULL default '',
00272 PRIMARY KEY (`value_id`),
00273 KEY `FK_ATTRIBUTE_VARCHAR_ENTITY_TYPE` (`entity_type_id`),
00274 KEY `FK_ATTRIBUTE_VARCHAR_ATTRIBUTE` (`attribute_id`),
00275 KEY `FK_ATTRIBUTE_VARCHAR_STORE` (`store_id`),
00276 KEY `FK_ATTRIBUTE_VARCHAR_ENTITY` (`entity_id`),
00277 KEY `value_by_attribute` (`attribute_id`,`value`),
00278 KEY `value_by_entity_type` (`entity_type_id`,`value`),
00279 CONSTRAINT `FK_EAV_ENTITY_VARCHAR_ENTITY` FOREIGN KEY (`entity_id`) REFERENCES `{$this->getTable('eav_entity')}` (`entity_id`) ON DELETE CASCADE ON UPDATE CASCADE,
00280 CONSTRAINT `FK_EAV_ENTITY_VARCHAR_ENTITY_TYPE` FOREIGN KEY (`entity_type_id`) REFERENCES `{$this->getTable('eav_entity_type')}` (`entity_type_id`) ON DELETE CASCADE ON UPDATE CASCADE,
00281 CONSTRAINT `FK_EAV_ENTITY_VARCHAR_STORE` FOREIGN KEY (`store_id`) REFERENCES `{$this->getTable('core_store')}` (`store_id`) ON DELETE CASCADE ON UPDATE CASCADE
00282 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Varchar values of attributes';
00283
00284 ");
00285
00286 $installer->endSetup();