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('tag')};
00035 CREATE TABLE {$this->getTable('tag')} (
00036 `tag_id` int(11) unsigned NOT NULL auto_increment,
00037 `name` varchar(255) NOT NULL default '',
00038 `status` smallint(6) NOT NULL default '0',
00039 PRIMARY KEY (`tag_id`)
00040 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
00041
00042 -- DROP TABLE IF EXISTS {$this->getTable('tag_relation')};
00043 CREATE TABLE {$this->getTable('tag_relation')} (
00044 `tag_relation_id` int(11) unsigned NOT NULL auto_increment,
00045 `tag_id` int(11) unsigned NOT NULL default '0',
00046 `customer_id` int(10) unsigned NOT NULL default '0',
00047 `product_id` int(11) unsigned NOT NULL default '0',
00048 `store_id` smallint(6) unsigned NOT NULL default '1',
00049 `active` tinyint (1) unsigned NOT NULL default '1',
00050 `created_at` datetime default NULL,
00051 PRIMARY KEY (`tag_relation_id`),
00052 KEY `FK_TAG_RELATION_TAG` (`tag_id`),
00053 KEY `FK_TAG_RELATION_CUSTOMER` (`customer_id`),
00054 KEY `FK_TAG_RELATION_PRODUCT` (`product_id`),
00055 KEY `FK_TAG_RELATION_STORE` (`store_id`),
00056 CONSTRAINT `FK_TAG_RELATION_PRODUCT` FOREIGN KEY (`product_id`) REFERENCES {$this->getTable('catalog_product_entity')} (`entity_id`) ON DELETE CASCADE ON UPDATE CASCADE,
00057 CONSTRAINT `tag_relation_ibfk_1` FOREIGN KEY (`tag_id`) REFERENCES {$this->getTable('tag')} (`tag_id`) ON DELETE CASCADE,
00058 CONSTRAINT `tag_relation_ibfk_2` FOREIGN KEY (`customer_id`) REFERENCES {$this->getTable('customer_entity')} (`entity_id`) ON DELETE CASCADE,
00059 CONSTRAINT `tag_relation_ibfk_4` FOREIGN KEY (`store_id`) REFERENCES {$this->getTable('core_store')} (`store_id`) ON DELETE CASCADE
00060 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
00061
00062 -- DROP TABLE IF EXISTS {$this->getTable('tag_summary')};
00063 CREATE TABLE {$this->getTable('tag_summary')} (
00064 `tag_id` int(11) unsigned NOT NULL default '0',
00065 `store_id` smallint(5) unsigned NOT NULL default '0',
00066 `customers` int(11) unsigned NOT NULL default '0',
00067 `products` int(11) unsigned NOT NULL default '0',
00068 `uses` int(11) unsigned NOT NULL default '0',
00069 `historical_uses` int(11) unsigned NOT NULL default '0',
00070 `popularity` int(11) unsigned NOT NULL default '0',
00071 PRIMARY KEY (`tag_id`,`store_id`),
00072 CONSTRAINT `TAG_SUMMARY_TAG` FOREIGN KEY (`tag_id`) REFERENCES {$this->getTable('tag')} (`tag_id`) ON DELETE CASCADE
00073 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
00074
00075 ");
00076
00077 $installer->endSetup();