START TRANSACTION;

CREATE TABLE `exercise_plan_template` (
	`exercise_plan_template_id` INT(11) NOT NULL AUTO_INCREMENT,
	`template_type` ENUM('special','mini_test_set') NULL DEFAULT NULL COLLATE 'utf8_hungarian_ci',
	`name` CHAR(50) NULL DEFAULT NULL COLLATE 'utf8_hungarian_ci',
	`description` TEXT NULL DEFAULT NULL COLLATE 'utf8_hungarian_ci',
	PRIMARY KEY (`exercise_plan_template_id`) USING BTREE,
	INDEX `template_type` (`template_type`) USING BTREE
)
COLLATE='utf8_hungarian_ci'
ENGINE=InnoDB
;

CREATE TABLE `exercise_plan_template_detail` (
	`exercise_plan_template_detail_id` INT(11) NOT NULL AUTO_INCREMENT,
	`exercise_plan_template_id` INT(11) NOT NULL DEFAULT '0',
	`exercise_type_id` INT(11) NOT NULL DEFAULT '0',
	`quantity` DOUBLE NULL DEFAULT '0',
	`quantity_unit_quantity` DOUBLE NULL DEFAULT '0',
	`serie` INT(11) NULL DEFAULT '0',
	`resting_time` TIME NULL DEFAULT '00:00:00',
	PRIMARY KEY (`exercise_plan_template_detail_id`) USING BTREE,
	INDEX `exercise_type_id` (`exercise_type_id`) USING BTREE,
	INDEX `exercise_plan_template_id` (`exercise_plan_template_id`) USING BTREE
)
COLLATE='utf8_hungarian_ci'
ENGINE=InnoDB
;

CREATE TABLE `exercise_plan_template_translation` (
	`translation_id` INT(11) NOT NULL AUTO_INCREMENT,
	`exercise_plan_template_id` INT(11) NULL DEFAULT NULL,
	`language_code` CHAR(2) NOT NULL DEFAULT '0' COLLATE 'utf8_hungarian_ci',
	`name` CHAR(50) NULL DEFAULT '0' COLLATE 'utf8_hungarian_ci',
	`description` TEXT NULL DEFAULT NULL COLLATE 'utf8_hungarian_ci',
	PRIMARY KEY (`translation_id`) USING BTREE
)
COLLATE='utf8_hungarian_ci'
ENGINE=InnoDB
;

ALTER TABLE `exercise_plan`
	ADD COLUMN `type` ENUM('custom','mini_test_set','special') NULL DEFAULT NULL AFTER `date_upd`,
	ADD COLUMN `exercise_plan_template_id` INT NULL DEFAULT NULL AFTER `type`;

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

COMMIT;

