CREATE TABLE `qs_WideSlideLinkType` ( `id` char(16) NOT NULL, `title` varchar(255) NOT NULL, `sorter` int(11) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; INSERT INTO `qs_WideSlideLinkType` (`id`, `title`, `sorter`) VALUES ('cms', 'Site Page', 2), ('event', 'Event', 3), ('url', 'URL', 1); ALTER TABLE `qs_WideSlide` CHANGE `linkType` `linkType` CHAR( 16 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL; update `qs_WideSlide` set `linkType` = null WHERE `linkType` = 'none'; ALTER TABLE `qs_WideSlide` ADD INDEX ( `linkType` ); ALTER TABLE `qs_WideSlide` ADD FOREIGN KEY ( `linkType` ) REFERENCES `qs_WideSlideLinkType` (`id`) ON DELETE RESTRICT ON UPDATE CASCADE ; ALTER TABLE `qs_WideSlide` ADD `eventId` INT( 10 ) UNSIGNED NOT NULL AFTER `linkType`; ALTER TABLE `qs_WideSlide` CHANGE `eventId` `eventId` INT( 10 ) UNSIGNED NULL DEFAULT NULL; ALTER TABLE `qs_WideSlide` CHANGE `pageId` `pageId` INT( 11 ) NULL DEFAULT NULL; ALTER TABLE `qs_WideSlide` CHANGE `url` `url` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL; ALTER TABLE `qs_WideSlide` CHANGE `linkText` `linkText` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL;