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 $conn->dropForeignKey('poll_answer', 'FK_POLL_PARENT');
00028 $conn->dropForeignKey('poll_vote', 'FK_POLL_ANSWER');
00029 $this->startSetup()
00030 ->run("
00031 ALTER TABLE {$this->getTable('poll')} CHANGE `poll_id` `poll_id` INT UNSIGNED NOT NULL AUTO_INCREMENT;
00032 ALTER TABLE {$this->getTable('poll_answer')} CHANGE `poll_id` `poll_id` INT UNSIGNED NOT NULL DEFAULT '0';
00033 ALTER TABLE {$this->getTable('poll_answer')} CHANGE `answer_id` `answer_id` INT UNSIGNED NOT NULL AUTO_INCREMENT;
00034 ALTER TABLE {$this->getTable('poll_vote')} CHANGE `poll_id` `poll_id` INT UNSIGNED NOT NULL DEFAULT '0';
00035 ALTER TABLE {$this->getTable('poll_vote')} CHANGE `poll_answer_id` `poll_answer_id` INT UNSIGNED NOT NULL DEFAULT '0';
00036 CREATE TABLE {$this->getTable('poll_store')} (
00037 `poll_id` int UNSIGNED NOT NULL,
00038 `store_id` smallint(5) unsigned NOT NULL,
00039 PRIMARY KEY (`poll_id`,`store_id`),
00040 CONSTRAINT `FK_POLL_STORE` FOREIGN KEY (`poll_id`) REFERENCES {$this->getTable('poll')} (`poll_id`) ON DELETE CASCADE
00041 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
00042 ALTER TABLE `{$this->getTable('poll_answer')}` ADD CONSTRAINT `FK_POLL_PARENT` FOREIGN KEY (`poll_id`) REFERENCES {$this->getTable('poll')} (`poll_id`) ON DELETE CASCADE ON UPDATE CASCADE;
00043 ALTER TABLE `{$this->getTable('poll_vote')}` ADD CONSTRAINT `FK_POLL_ANSWER` FOREIGN KEY (`poll_answer_id`) REFERENCES {$this->getTable('poll_answer')} (`answer_id`) ON DELETE CASCADE ON UPDATE CASCADE;
00044 ")
00045 ->endSetup();