startSetup(); $voteTable = $this->getTable('rating_option_vote'); $reviewTable = $this->getTable('review'); $this->run(" DELETE FROM `{$voteTable}` WHERE `review_id` NOT IN (SELECT review_id FROM `{$reviewTable}`); "); $this->run(" ALTER TABLE `{$voteTable}` ADD CONSTRAINT `FK_RATING_OPTION_REVIEW_ID` FOREIGN KEY (`review_id`) REFERENCES `{$reviewTable}` (`review_id`) ON DELETE CASCADE ON UPDATE CASCADE; "); $this->endSetup();