
ALTER TABLE `survey_items_display` ADD COLUMN `saved` DATETIME NULL;
UPDATE `survey_items_display` SET `saved` = `answered_time`;
UPDATE `survey_items_display` SET `answered` = NULL;
ALTER TABLE `survey_items_display` 
DROP COLUMN `answered_time`,
DROP COLUMN `modified`,
CHANGE COLUMN `answered` `answered` DATETIME NULL DEFAULT NULL ,
ADD COLUMN `answer` TEXT NULL DEFAULT NULL AFTER `session_id`,
ADD COLUMN `shown` DATETIME NULL DEFAULT NULL AFTER `saved`,
ADD COLUMN `shown_relative` DOUBLE NULL DEFAULT NULL AFTER `shown`,
ADD COLUMN `answered_relative` DOUBLE NULL DEFAULT NULL AFTER `answered`,
DROP INDEX `answered` ,
ADD INDEX `answered` (`session_id` ASC, `saved` ASC);

ALTER TABLE `survey_items_display` 
ADD CONSTRAINT `sessionidx`
FOREIGN KEY (`session_id`)
REFERENCES `survey_unit_sessions` (`id`)
ON DELETE CASCADE
ON UPDATE NO ACTION;


