CREATE TABLE IF NOT EXISTS `exercise_device_alternative` (
  `exercise_device_alternative_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `exercise_device_parent_id` int(11) NOT NULL DEFAULT 0,
  `exercise_device_child_id` int(11) NOT NULL DEFAULT 0,
  PRIMARY KEY (`exercise_device_alternative_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_hungarian_ci;

CREATE TABLE IF NOT EXISTS `exercise_type_alternative` (
  `exercise_type_alternative_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `exercise_type_parent_id` int(11) NOT NULL DEFAULT 0,
  `exercise_type_child_id` int(11) NOT NULL DEFAULT 0,
  PRIMARY KEY (`exercise_type_alternative_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_hungarian_ci;

CREATE TABLE IF NOT EXISTS `exercise_type_parents` (
  `exercise_type_parents_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `exercise_tree_id` int(11) NOT NULL DEFAULT 0,
  `exercise_type_id` int(11) NOT NULL DEFAULT 0,
  PRIMARY KEY (`exercise_type_parents_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_hungarian_ci;

INSERT INTO exercise_type_parents (exercise_tree_id, exercise_type_id)
 SELECT tree_id, exercise_type_id FROM exercise_type;

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