1 UP_SQL = """ 2 CREATE TABLE afe_test_parameters ( 3 id INT PRIMARY KEY AUTO_INCREMENT, 4 test_id INT NOT NULL, 5 name VARCHAR(255) NOT NULL 6 ) ENGINE = InnoDB; 7 8 ALTER TABLE afe_test_parameters 9 ADD CONSTRAINT afe_test_parameters_test_ibfk 10 FOREIGN KEY (test_id) REFERENCES afe_autotests (id); 11 12 ALTER TABLE afe_test_parameters 13 ADD CONSTRAINT afe_test_parameters_unique 14 UNIQUE KEY (test_id, name); 15 16 17 CREATE TABLE afe_parameterized_jobs ( 18 id INT PRIMARY KEY AUTO_INCREMENT, 19 test_id INT NOT NULL, 20 label_id INT DEFAULT NULL, 21 use_container TINYINT(1) DEFAULT 0, 22 profile_only TINYINT(1) DEFAULT 0, 23 upload_kernel_config TINYINT(1) DEFAULT 0 24 ) ENGINE = InnoDB; 25 26 ALTER TABLE afe_parameterized_jobs 27 ADD CONSTRAINT afe_parameterized_jobs_test_ibfk 28 FOREIGN KEY (test_id) REFERENCES afe_autotests (id); 29 30 ALTER TABLE afe_parameterized_jobs 31 ADD CONSTRAINT afe_parameterized_jobs_label_ibfk 32 FOREIGN KEY (label_id) REFERENCES afe_labels (id); 33 34 35 CREATE TABLE afe_kernels ( 36 id INT PRIMARY KEY AUTO_INCREMENT, 37 version VARCHAR(255) NOT NULL, 38 cmdline VARCHAR(255) DEFAULT '' 39 ) ENGINE = InnoDB; 40 41 ALTER TABLE afe_kernels 42 ADD CONSTRAINT afe_kernals_unique 43 UNIQUE KEY (version, cmdline); 44 45 46 CREATE TABLE afe_parameterized_jobs_kernels ( 47 parameterized_job_id INT NOT NULL, 48 kernel_id INT NOT NULL, 49 PRIMARY KEY (parameterized_job_id, kernel_id) 50 ) ENGINE = InnoDB; 51 52 ALTER TABLE afe_parameterized_jobs_kernels 53 ADD CONSTRAINT afe_parameterized_jobs_kernels_parameterized_job_ibfk 54 FOREIGN KEY (parameterized_job_id) REFERENCES afe_parameterized_jobs (id); 55 56 57 CREATE TABLE afe_parameterized_jobs_profilers ( 58 id INT PRIMARY KEY AUTO_INCREMENT, 59 parameterized_job_id INT NOT NULL, 60 profiler_id INT NOT NULL 61 ) ENGINE = InnoDB; 62 63 ALTER TABLE afe_parameterized_jobs_profilers 64 ADD CONSTRAINT afe_parameterized_jobs_profilers_parameterized_job_ibfk 65 FOREIGN KEY (parameterized_job_id) REFERENCES afe_parameterized_jobs (id); 66 67 ALTER TABLE afe_parameterized_jobs_profilers 68 ADD CONSTRAINT afe_parameterized_jobs_profilers_profile_ibfk 69 FOREIGN KEY (profiler_id) REFERENCES afe_profilers (id); 70 71 ALTER TABLE afe_parameterized_jobs_profilers 72 ADD CONSTRAINT afe_parameterized_jobs_profilers_unique 73 UNIQUE KEY (parameterized_job_id, profiler_id); 74 75 76 CREATE TABLE afe_parameterized_job_profiler_parameters ( 77 id INT PRIMARY KEY AUTO_INCREMENT, 78 parameterized_job_profiler_id INT NOT NULL, 79 parameter_name VARCHAR(255) NOT NULL, 80 parameter_value TEXT NOT NULL, 81 parameter_type ENUM('int', 'float', 'string') 82 ) ENGINE = InnoDB; 83 84 ALTER TABLE afe_parameterized_job_profiler_parameters 85 ADD CONSTRAINT afe_parameterized_job_profiler_parameters_ibfk 86 FOREIGN KEY (parameterized_job_profiler_id) 87 REFERENCES afe_parameterized_jobs_profilers (id); 88 89 ALTER TABLE afe_parameterized_job_profiler_parameters 90 ADD CONSTRAINT afe_parameterized_job_profiler_parameters_unique 91 UNIQUE KEY (parameterized_job_profiler_id, parameter_name); 92 93 94 CREATE TABLE afe_parameterized_job_parameters ( 95 id INT PRIMARY KEY AUTO_INCREMENT, 96 parameterized_job_id INT NOT NULL, 97 test_parameter_id INT NOT NULL, 98 parameter_value TEXT NOT NULL, 99 parameter_type ENUM('int', 'float', 'string') 100 ) ENGINE = InnoDB; 101 102 ALTER TABLE afe_parameterized_job_parameters 103 ADD CONSTRAINT afe_parameterized_job_parameters_job_ibfk 104 FOREIGN KEY (parameterized_job_id) REFERENCES afe_parameterized_jobs (id); 105 106 ALTER TABLE afe_parameterized_job_parameters 107 ADD CONSTRAINT afe_parameterized_job_parameters_test_parameter_ibfk 108 FOREIGN KEY (test_parameter_id) REFERENCES afe_test_parameters (id); 109 110 ALTER TABLE afe_parameterized_job_parameters 111 ADD CONSTRAINT afe_parameterized_job_parameters_unique 112 UNIQUE KEY (parameterized_job_id, test_parameter_id); 113 114 115 ALTER TABLE afe_jobs 116 MODIFY COLUMN control_file TEXT DEFAULT NULL; 117 118 ALTER TABLE afe_jobs 119 ADD COLUMN parameterized_job_id INT DEFAULT NULL; 120 121 ALTER TABLE afe_jobs 122 ADD CONSTRAINT afe_jobs_parameterized_job_ibfk 123 FOREIGN KEY (parameterized_job_id) REFERENCES afe_parameterized_jobs (id); 124 """ 125 126 127 DOWN_SQL = """ 128 ALTER TABLE afe_jobs 129 DROP FOREIGN KEY afe_jobs_parameterized_job_ibfk; 130 131 ALTER TABLE afe_jobs 132 DROP COLUMN parameterized_job_id; 133 134 ALTER TABLE afe_jobs 135 MODIFY COLUMN control_file TEXT; 136 137 DROP TABLE afe_parameterized_job_parameters; 138 DROP TABLE afe_parameterized_job_profiler_parameters; 139 DROP TABLE afe_parameterized_jobs_profilers; 140 DROP TABLE afe_parameterized_jobs_kernels; 141 DROP TABLE afe_kernels; 142 DROP TABLE afe_parameterized_jobs; 143 DROP TABLE afe_test_parameters; 144 """ 145