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('poll')};
00035 CREATE TABLE {$this->getTable('poll')} (
00036 `poll_id` int(10) unsigned NOT NULL auto_increment,
00037 `poll_title` varchar(255) NOT NULL default '',
00038 `votes_count` int(10) unsigned NOT NULL default '0',
00039 `store_id` smallint(6) NOT NULL default '0',
00040 `date_posted` datetime NOT NULL default '0000-00-00 00:00:00',
00041 `date_closed` datetime default NULL,
00042 `active` smallint(6) NOT NULL default '1',
00043 `closed` tinyint(1) NOT NULL default '0',
00044 `answers_display` smallint(6) default NULL,
00045 PRIMARY KEY (`poll_id`)
00046 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
00047
00048 insert into {$this->getTable('poll')}(`poll_id`,`poll_title`,`votes_count`,`store_id`,`date_posted`,`date_closed`,`active`,`closed`,`answers_display`) values (1,'What is your favorite color',5,1, NOW(),NULL,1,0,NULL);
00049
00050 -- DROP TABLE IF EXISTS {$this->getTable('poll_answer')};
00051 CREATE TABLE {$this->getTable('poll_answer')} (
00052 `answer_id` int(10) unsigned NOT NULL auto_increment,
00053 `poll_id` int(10) unsigned NOT NULL default '0',
00054 `answer_title` varchar(255) NOT NULL default '',
00055 `votes_count` int(10) unsigned NOT NULL default '0',
00056 `answer_order` smallint(6) NOT NULL default '0',
00057 PRIMARY KEY (`answer_id`),
00058 KEY `FK_POLL_PARENT` (`poll_id`),
00059 CONSTRAINT `FK_POLL_PARENT` FOREIGN KEY (`poll_id`) REFERENCES {$this->getTable('poll')} (`poll_id`) ON DELETE CASCADE ON UPDATE CASCADE
00060 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
00061
00062 insert into {$this->getTable('poll_answer')}(`answer_id`,`poll_id`,`answer_title`,`votes_count`,`answer_order`) values (1,1,'Green',4,0),(2,1,'Red',1,0),(3,1,'Black',0,0),(4,1,'Magenta',0,0);
00063
00064 -- DROP TABLE IF EXISTS {$this->getTable('poll_store')};
00065 CREATE TABLE {$this->getTable('poll_store')} (
00066 `poll_id` int(10) unsigned NOT NULL default '0',
00067 `store_id` smallint(5) unsigned NOT NULL default '0',
00068 PRIMARY KEY (`poll_id`,`store_id`),
00069 CONSTRAINT `FK_POLL_STORE` FOREIGN KEY (`poll_id`) REFERENCES {$this->getTable('poll')} (`poll_id`) ON DELETE CASCADE
00070 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
00071
00072 INSERT INTO {$this->getTable('poll_store')} (`poll_id`,`store_id`) VALUES(1,1);
00073 -- DROP TABLE IF EXISTS {$this->getTable('poll_vote')};
00074 CREATE TABLE {$this->getTable('poll_vote')} (
00075 `vote_id` int(10) unsigned NOT NULL auto_increment,
00076 `poll_id` int(10) unsigned NOT NULL default '0',
00077 `poll_answer_id` int(10) unsigned NOT NULL default '0',
00078 `ip_address` bigint(20) default NULL,
00079 `customer_id` int(11) default NULL,
00080 `vote_time` timestamp NOT NULL,
00081 PRIMARY KEY (`vote_id`),
00082 KEY `FK_POLL_ANSWER` (`poll_answer_id`),
00083 CONSTRAINT `FK_POLL_ANSWER` FOREIGN KEY (`poll_answer_id`) REFERENCES {$this->getTable('poll_answer')} (`answer_id`) ON DELETE CASCADE ON UPDATE CASCADE
00084 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
00085
00086 ");
00087
00088 $installer->endSetup();