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