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('rating')};
00035 CREATE TABLE {$this->getTable('rating')} (
00036 `rating_id` smallint(6) unsigned NOT NULL auto_increment,
00037 `entity_id` smallint(6) unsigned NOT NULL default '0',
00038 `rating_code` varchar(64) NOT NULL default '',
00039 `position` tinyint(3) unsigned NOT NULL default '0',
00040 PRIMARY KEY (`rating_id`),
00041 UNIQUE KEY `IDX_CODE` (`rating_code`),
00042 KEY `FK_RATING_ENTITY` (`entity_id`),
00043 CONSTRAINT `FK_RATING_ENTITY_KEY` FOREIGN KEY (`entity_id`) REFERENCES {$this->getTable('rating_entity')} (`entity_id`) ON DELETE CASCADE ON UPDATE CASCADE
00044 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='ratings';
00045
00046 insert into {$this->getTable('rating')}(`rating_id`,`entity_id`,`rating_code`,`position`) values (1,1,'Quality',0),(2,1,'Value',0),(3,1,'Price',0);
00047
00048 -- DROP TABLE IF EXISTS {$this->getTable('rating_entity')};
00049 CREATE TABLE {$this->getTable('rating_entity')} (
00050 `entity_id` smallint(6) unsigned NOT NULL auto_increment,
00051 `entity_code` varchar(64) NOT NULL default '',
00052 PRIMARY KEY (`entity_id`),
00053 UNIQUE KEY `IDX_CODE` (`entity_code`)
00054 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Rating entities';
00055
00056 insert into {$this->getTable('rating_entity')}(`entity_id`,`entity_code`) values (1,'product'),(2,'product_review'),(3,'review');
00057
00058 -- DROP TABLE IF EXISTS {$this->getTable('rating_option')};
00059 CREATE TABLE {$this->getTable('rating_option')} (
00060 `option_id` int(10) unsigned NOT NULL auto_increment,
00061 `rating_id` smallint(6) unsigned NOT NULL default '0',
00062 `code` varchar(32) NOT NULL default '',
00063 `value` tinyint(3) unsigned NOT NULL default '0',
00064 `position` tinyint(3) unsigned NOT NULL default '0',
00065 PRIMARY KEY (`option_id`),
00066 KEY `FK_RATING_OPTION_RATING` (`rating_id`),
00067 CONSTRAINT `FK_RATING_OPTION_RATING` FOREIGN KEY (`rating_id`) REFERENCES {$this->getTable('rating')} (`rating_id`) ON DELETE CASCADE ON UPDATE CASCADE
00068 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Rating options';
00069
00070 insert into {$this->getTable('rating_option')}(`option_id`,`rating_id`,`code`,`value`,`position`) values (1,1,'1',1,1),(2,1,'2',2,2),(3,1,'3',3,3),(4,1,'4',4,4),(5,1,'5',5,5),(6,2,'1',1,1),(7,2,'2',2,2),(8,2,'3',3,3),(9,2,'4',4,4),(10,2,'5',5,5),(11,3,'1',1,1),(12,3,'2',2,2),(13,3,'3',3,3),(14,3,'4',4,4),(15,3,'5',5,5);
00071
00072 -- DROP TABLE IF EXISTS {$this->getTable('rating_option_vote')};
00073 CREATE TABLE {$this->getTable('rating_option_vote')} (
00074 `vote_id` bigint(20) unsigned NOT NULL auto_increment,
00075 `option_id` int(10) unsigned NOT NULL default '0',
00076 `remote_ip` varchar(16) NOT NULL default '',
00077 `remote_ip_long` int(11) NOT NULL default '0',
00078 `customer_id` int(11) unsigned default '0',
00079 `entity_pk_value` bigint(20) unsigned NOT NULL default '0',
00080 `rating_id` smallint(6) unsigned NOT NULL default '0',
00081 `review_id` bigint(20) unsigned default NULL,
00082 `percent` tinyint(3) NOT NULL default '0',
00083 `value` tinyint (3) NOT NULL default '0',
00084 PRIMARY KEY (`vote_id`),
00085 KEY `FK_RATING_OPTION_VALUE_OPTION` (`option_id`),
00086 CONSTRAINT `FK_RATING_OPTION_VALUE_OPTION` FOREIGN KEY (`option_id`) REFERENCES {$this->getTable('rating_option')} (`option_id`) ON DELETE CASCADE ON UPDATE CASCADE
00087 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Rating option values';
00088
00089 -- DROP TABLE IF EXISTS {$this->getTable('rating_option_vote_aggregated')};
00090 CREATE TABLE {$this->getTable('rating_option_vote_aggregated')} (
00091 `primary_id` int(11) NOT NULL auto_increment,
00092 `rating_id` smallint(6) unsigned NOT NULL default '0',
00093 `entity_pk_value` bigint(20) unsigned NOT NULL default '0',
00094 `vote_count` int(10) unsigned NOT NULL default '0',
00095 `vote_value_sum` int(10) unsigned NOT NULL default '0',
00096 `percent` tinyint(3) NOT NULL default '0',
00097 `store_id` smallint (5) unsigned NOT NULL DEFAULT '0',
00098 PRIMARY KEY (`primary_id`),
00099 KEY `FK_RATING_OPTION_VALUE_AGGREGATE` (`rating_id`),
00100 CONSTRAINT `FK_RATING_OPTION_VALUE_AGGREGATE` FOREIGN KEY (`rating_id`) REFERENCES {$this->getTable('rating')} (`rating_id`) ON DELETE CASCADE ON UPDATE CASCADE
00101 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
00102
00103 -- DROP TABLE IF EXISTS {$this->getTable('rating_store')};
00104 CREATE TABLE {$this->getTable('rating_store')} (
00105 `rating_id` smallint(6) unsigned NOT NULL default '0',
00106 `store_id` smallint(5) unsigned NOT NULL default '0',
00107 PRIMARY KEY (`rating_id`,`store_id`),
00108 CONSTRAINT `FK_RATING_STORE_RATING` FOREIGN KEY (`rating_id`) REFERENCES {$this->getTable('rating')} (`rating_id`) ON DELETE CASCADE
00109 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
00110
00111 -- DROP TABLE IF EXISTS {$this->getTable('rating_title')};
00112 CREATE TABLE {$this->getTable('rating_title')} (
00113 `rating_id` smallint(6) unsigned NOT NULL default '0',
00114 `store_id` smallint(5) unsigned NOT NULL default '0',
00115 `value` varchar(255) NOT NULL default '',
00116 PRIMARY KEY (`rating_id`,`store_id`),
00117 CONSTRAINT `FK_RATING_TITLE` FOREIGN KEY (`rating_id`) REFERENCES {$this->getTable('rating')} (`rating_id`)
00118 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
00119
00120 ");
00121
00122 $installer->endSetup();