1 UP_SQL = """\ 2 BEGIN; 3 4 SET storage_engine = InnoDB; 5 6 CREATE TABLE `planner_plan_host_labels` ( 7 `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, 8 `plan_id` integer NOT NULL, 9 `label_id` integer NOT NULL 10 ) 11 ; 12 ALTER TABLE `planner_plan_host_labels` ADD CONSTRAINT plan_host_labels_plan_id_fk FOREIGN KEY (`plan_id`) REFERENCES `planner_plans` (`id`); 13 ALTER TABLE `planner_plan_host_labels` ADD CONSTRAINT plan_host_labels_label_id_fk FOREIGN KEY (`label_id`) REFERENCES `afe_labels` (`id`); 14 15 16 ALTER TABLE `planner_tests` ADD COLUMN `alias` varchar(255) NOT NULL; 17 ALTER TABLE `planner_tests` ADD CONSTRAINT `tests_plan_id_alias_unique` UNIQUE KEY (`plan_id`, `alias`); 18 19 20 ALTER TABLE `planner_tests` ADD COLUMN `estimated_runtime` int NOT NULL; 21 22 23 ALTER TABLE `planner_test_runs` ADD COLUMN `host_id` int NOT NULL; 24 ALTER TABLE `planner_test_runs` ADD CONSTRAINT `test_runs_host_id_fk` FOREIGN KEY (`host_id`) REFERENCES `planner_hosts` (`id`); 25 26 COMMIT; 27 """ 28 29 DOWN_SQL = """\ 30 ALTER TABLE `planner_tests` DROP KEY `tests_plan_id_alias_unique`; 31 ALTER TABLE `planner_tests` DROP COLUMN `alias`; 32 ALTER TABLE `planner_tests` DROP COLUMN `estimated_runtime`; 33 ALTER TABLE `planner_test_runs` DROP FOREIGN KEY `test_runs_host_id_fk`; 34 ALTER TABLE `planner_test_runs` DROP COLUMN `host_id`; 35 DROP TABLE IF EXISTS `planner_plan_host_labels`; 36 """ 37