START TRANSACTION;

DROP TABLE `diet_user_sensitivity`;
DROP TABLE `diet_sensitivity`;

CREATE TABLE `diet_preference` (
	`id` INT(11) NOT NULL AUTO_INCREMENT,
	`type` CHAR(50) NULL DEFAULT NULL COLLATE 'utf8_hungarian_ci',
	`preference` CHAR(100) NOT NULL DEFAULT '' COLLATE 'utf8_hungarian_ci',
	PRIMARY KEY (`id`) USING BTREE
)
COLLATE='utf8_hungarian_ci'
ENGINE=InnoDB
;

ALTER TABLE `diet_user_preference`
	CHANGE COLUMN `raw_material_id` `diet_preference_id` INT(11) NULL DEFAULT '0' AFTER `diet_user_id`,
	ADD COLUMN `preference` CHAR(100) NULL DEFAULT NULL AFTER `diet_preference_id`,
	ADD COLUMN `preference_type` CHAR(50) NULL DEFAULT NULL AFTER `preference`,
	DROP COLUMN `temperature`;

UPDATE configuration set config_value = "1.2.5", date_change=CURRENT_DATE WHERE config_key = "db_version";

COMMIT;