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('review')};
00035 CREATE TABLE {$this->getTable('review')} (
00036 `review_id` bigint(20) unsigned NOT NULL auto_increment,
00037 `created_at` datetime NOT NULL default '0000-00-00 00:00:00',
00038 `entity_id` smallint(5) unsigned NOT NULL default '0',
00039 `entity_pk_value` int(10) unsigned NOT NULL default '0',
00040 `status_id` tinyint(3) unsigned NOT NULL default '0',
00041 PRIMARY KEY (`review_id`),
00042 KEY `FK_REVIEW_ENTITY` (`entity_id`),
00043 KEY `FK_REVIEW_STATUS` (`status_id`),
00044 KEY `FK_REVIEW_PARENT_PRODUCT` (`entity_pk_value`),
00045 CONSTRAINT `FK_REVIEW_ENTITY` FOREIGN KEY (`entity_id`) REFERENCES {$this->getTable('review_entity')} (`entity_id`) ON DELETE CASCADE ON UPDATE CASCADE,
00046 CONSTRAINT `FK_REVIEW_PARENT_PRODUCT` FOREIGN KEY (`entity_pk_value`) REFERENCES {$this->getTable('catalog_product_entity')} (`entity_id`) ON DELETE CASCADE ON UPDATE CASCADE,
00047 CONSTRAINT `FK_REVIEW_STATUS` FOREIGN KEY (`status_id`) REFERENCES {$this->getTable('review_status')} (`status_id`)
00048 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Review base information';
00049
00050 -- DROP TABLE IF EXISTS {$this->getTable('review_detail')};
00051 CREATE TABLE {$this->getTable('review_detail')} (
00052 `detail_id` bigint(20) unsigned NOT NULL auto_increment,
00053 `review_id` bigint(20) unsigned NOT NULL default '0',
00054 `store_id` smallint(6) unsigned NOT NULL default '0',
00055 `title` varchar(255) NOT NULL default '',
00056 `detail` text NOT NULL,
00057 `nickname` varchar(128) NOT NULL default '',
00058 `customer_id` int(10) unsigned default NULL,
00059 PRIMARY KEY (`detail_id`),
00060 KEY `FK_REVIEW_DETAIL_REVIEW` (`review_id`),
00061 CONSTRAINT `FK_REVIEW_DETAIL_REVIEW` FOREIGN KEY (`review_id`) REFERENCES {$this->getTable('review')} (`review_id`) ON DELETE CASCADE ON UPDATE CASCADE
00062 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Review detail information';
00063
00064 -- DROP TABLE IF EXISTS {$this->getTable('review_entity')};
00065 CREATE TABLE {$this->getTable('review_entity')} (
00066 `entity_id` smallint(5) unsigned NOT NULL auto_increment,
00067 `entity_code` varchar(32) NOT NULL default '',
00068 PRIMARY KEY (`entity_id`)
00069 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Review entities';
00070
00071 insert into {$this->getTable('review_entity')}(`entity_id`,`entity_code`) values (1,'product'),(2,'customer'),(3,'category');
00072
00073 -- DROP TABLE IF EXISTS {$this->getTable('review_entity_summary')};
00074 CREATE TABLE {$this->getTable('review_entity_summary')} (
00075 `primary_id` bigint(20) NOT NULL auto_increment,
00076 `entity_pk_value` bigint(20) NOT NULL default '0',
00077 `entity_type` tinyint(4) NOT NULL default '0',
00078 `reviews_count` smallint(6) NOT NULL default '0',
00079 `rating_summary` tinyint(4) NOT NULL default '0',
00080 `store_id` smallint (5) unsigned NOT NULL default '0',
00081 PRIMARY KEY (`primary_id`)
00082 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
00083
00084 -- DROP TABLE IF EXISTS {$this->getTable('review_status')};
00085 CREATE TABLE {$this->getTable('review_status')} (
00086 `status_id` tinyint(3) unsigned NOT NULL auto_increment,
00087 `status_code` varchar(32) NOT NULL default '',
00088 PRIMARY KEY (`status_id`)
00089 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Review statuses';
00090
00091 insert into {$this->getTable('review_status')}(`status_id`,`status_code`) values (1,'Approved'),(2,'Pending'),(3,'Not Approved');
00092
00093 -- DROP TABLE IF EXISTS `{$this->getTable('review_store')}`;
00094 CREATE TABLE `{$this->getTable('review_store')}` (
00095 `review_id` bigint(20) unsigned NOT NULL,
00096 `store_id` smallint(5) unsigned NOT NULL,
00097 PRIMARY KEY (`review_id`,`store_id`),
00098 CONSTRAINT `FK_REVIEW_STORE_REVIEW` FOREIGN KEY (`review_id`) REFERENCES `{$this->getTable('review')}` (`review_id`) ON DELETE CASCADE
00099 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
00100
00101 ");
00102
00103 $installer->endSetup();