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 $installer = $this;
00029 $connection = $installer->getConnection();
00030
00031
00032
00033 $installer->startSetup();
00034
00035 $installer->run("
00036 DROP TABLE IF EXISTS `{$installer->getTable('catalogsearch_fulltext')}`;
00037 CREATE TABLE `{$installer->getTable('catalogsearch_fulltext')}` (
00038 `product_id` int(10) unsigned NOT NULL,
00039 `store_id` smallint(5) unsigned NOT NULL,
00040 `data_index` longtext NOT NULL,
00041 PRIMARY KEY (`product_id`,`store_id`),
00042 FULLTEXT KEY `data_index` (`data_index`)
00043 ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
00044
00045 CREATE TABLE `{$installer->getTable('catalogsearch_result')}` (
00046 `query_id` int(10) unsigned NOT NULL,
00047 `product_id` int(10) unsigned NOT NULL,
00048 `relevance` decimal(6,4) NOT NULL default '0.0000',
00049 PRIMARY KEY (`query_id`,`product_id`),
00050 KEY `IDX_QUERY` (`query_id`),
00051 KEY `IDX_PRODUCT` (`product_id`),
00052 KEY `IDX_RELEVANCE` (`query_id`, `relevance`),
00053 CONSTRAINT `FK_CATALOGSEARCH_RESULT_QUERY` FOREIGN KEY (`query_id`) REFERENCES `{$installer->getTable('catalogsearch_query')}` (`query_id`) ON DELETE CASCADE ON UPDATE CASCADE,
00054 CONSTRAINT `FK_CATALOGSEARCH_RESULT_CATALOG_PRODUCT` FOREIGN KEY (`product_id`) REFERENCES `{$installer->getTable('catalog_product_entity')}` (`entity_id`) ON DELETE CASCADE ON UPDATE CASCADE
00055 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
00056 ");
00057
00058 $connection->dropForeignKey($installer->getTable('catalogsearch_query'), 'FK_catalogsearch_query');
00059 $connection->dropKey($installer->getTable('catalogsearch_query'), 'FK_catalogsearch_query');
00060 $connection->addConstraint('FK_CATALOGSEARCH_QUERY_STORE',
00061 $installer->getTable('catalogsearch_query'), 'store_id',
00062 $installer->getTable('core_store'), 'store_id'
00063 );
00064 $connection->addColumn($installer->getTable('catalogsearch_query'), 'is_active', 'tinyint(1) DEFAULT 1 AFTER `display_in_terms`');
00065 $connection->addColumn($installer->getTable('catalogsearch_query'), 'is_processed', 'tinyint(1) DEFAULT 0 AFTER `is_active`');
00066
00067 $connection->dropKey($installer->getTable('catalogsearch_query'), 'search_query');
00068 $connection->addKey($installer->getTable('catalogsearch_query'), 'IDX_SEARCH_QUERY', array(
00069 'query_text', 'store_id', 'popularity'
00070 ));
00071
00072 $installer->endSetup();
00073
00074
00075