ALTER TABLE `mm_EventOption` ADD `includeInCertificate` ENUM('n','y') NOT NULL DEFAULT 'n' AFTER `title`; ALTER TABLE `mm_EventOptionChoice` ADD `synopsis` TEXT NOT NULL AFTER `title`; ALTER TABLE `mm_Event` ADD `certificateIntro` TEXT NULL DEFAULT NULL AFTER `ceus`; ALTER TABLE `mm_EventAttendeeOption` ADD `optionId` INT UNSIGNED NULL AFTER `attendeeId`, ADD `firstChoiceId` INT UNSIGNED NULL AFTER `optionId`, ADD `secondChoiceId` INT UNSIGNED NULL AFTER `firstChoiceId`; UPDATE `mm_EventAttendeeOption` AS `eao` JOIN `mm_EventAttendee` AS `ea` ON `ea`.`id` = `eao`.`attendeeId` JOIN `mm_EventOption` AS `eo` ON `eo`.`eventId` = `ea`.`eventId` AND `eo`.`title` = `eao`.`optionName` SET `eao`.`optionId` = `eo`.`id`; UPDATE `mm_EventAttendeeOption` AS `eao` JOIN `mm_EventOptionChoice` AS `eoc` ON `eoc`.`optionId` = `eao`.`optionId` AND `eoc`.`title` = `eao`.`firstChoice` SET `eao`.`firstChoiceId` = `eoc`.`id`; UPDATE `mm_EventAttendeeOption` AS `eao` JOIN `mm_EventOptionChoice` AS `eoc` ON `eoc`.`optionId` = `eao`.`optionId` AND `eoc`.`title` = `eao`.`secondChoice` SET `eao`.`secondChoiceId` = `eoc`.`id`; ALTER TABLE `mm_EventAttendeeOption` ADD INDEX(`optionId`); ALTER TABLE `mm_EventAttendeeOption` ADD INDEX(`firstChoiceId`); ALTER TABLE `mm_EventAttendeeOption` ADD INDEX(`secondChoiceId`); ALTER TABLE `mm_EventAttendeeOption` ADD FOREIGN KEY (`optionId`) REFERENCES `mm_EventOption`(`id`) ON DELETE SET NULL ON UPDATE RESTRICT; ALTER TABLE `mm_EventAttendeeOption` ADD FOREIGN KEY (`firstChoiceId`) REFERENCES `mm_EventOptionChoice`(`id`) ON DELETE SET NULL ON UPDATE RESTRICT; ALTER TABLE `mm_EventAttendeeOption` ADD FOREIGN KEY (`secondChoiceId`) REFERENCES `mm_EventOptionChoice`(`id`) ON DELETE SET NULL ON UPDATE RESTRICT; ALTER TABLE `mm_EventAttendeeOption` DROP `optionName`, DROP `firstChoice`, DROP `secondChoice`;