• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1UP_SQL = """
2CREATE 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
8ALTER TABLE afe_test_parameters
9ADD CONSTRAINT afe_test_parameters_test_ibfk
10FOREIGN KEY (test_id) REFERENCES afe_autotests (id);
11
12ALTER TABLE afe_test_parameters
13ADD CONSTRAINT afe_test_parameters_unique
14UNIQUE KEY (test_id, name);
15
16
17CREATE 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
26ALTER TABLE afe_parameterized_jobs
27ADD CONSTRAINT afe_parameterized_jobs_test_ibfk
28FOREIGN KEY (test_id) REFERENCES afe_autotests (id);
29
30ALTER TABLE afe_parameterized_jobs
31ADD CONSTRAINT afe_parameterized_jobs_label_ibfk
32FOREIGN KEY (label_id) REFERENCES afe_labels (id);
33
34
35CREATE 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
41ALTER TABLE afe_kernels
42ADD CONSTRAINT afe_kernals_unique
43UNIQUE KEY (version, cmdline);
44
45
46CREATE 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
52ALTER TABLE afe_parameterized_jobs_kernels
53ADD CONSTRAINT afe_parameterized_jobs_kernels_parameterized_job_ibfk
54FOREIGN KEY (parameterized_job_id) REFERENCES afe_parameterized_jobs (id);
55
56
57CREATE 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
63ALTER TABLE afe_parameterized_jobs_profilers
64ADD CONSTRAINT afe_parameterized_jobs_profilers_parameterized_job_ibfk
65FOREIGN KEY (parameterized_job_id) REFERENCES afe_parameterized_jobs (id);
66
67ALTER TABLE afe_parameterized_jobs_profilers
68ADD CONSTRAINT afe_parameterized_jobs_profilers_profile_ibfk
69FOREIGN KEY (profiler_id) REFERENCES afe_profilers (id);
70
71ALTER TABLE afe_parameterized_jobs_profilers
72ADD CONSTRAINT afe_parameterized_jobs_profilers_unique
73UNIQUE KEY (parameterized_job_id, profiler_id);
74
75
76CREATE 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
84ALTER TABLE afe_parameterized_job_profiler_parameters
85ADD CONSTRAINT afe_parameterized_job_profiler_parameters_ibfk
86FOREIGN KEY (parameterized_job_profiler_id)
87  REFERENCES afe_parameterized_jobs_profilers (id);
88
89ALTER TABLE afe_parameterized_job_profiler_parameters
90ADD CONSTRAINT afe_parameterized_job_profiler_parameters_unique
91UNIQUE KEY (parameterized_job_profiler_id, parameter_name);
92
93
94CREATE 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
102ALTER TABLE afe_parameterized_job_parameters
103ADD CONSTRAINT afe_parameterized_job_parameters_job_ibfk
104FOREIGN KEY (parameterized_job_id) REFERENCES afe_parameterized_jobs (id);
105
106ALTER TABLE afe_parameterized_job_parameters
107ADD CONSTRAINT afe_parameterized_job_parameters_test_parameter_ibfk
108FOREIGN KEY (test_parameter_id) REFERENCES afe_test_parameters (id);
109
110ALTER TABLE afe_parameterized_job_parameters
111ADD CONSTRAINT afe_parameterized_job_parameters_unique
112UNIQUE KEY (parameterized_job_id, test_parameter_id);
113
114
115ALTER TABLE afe_jobs
116MODIFY COLUMN control_file TEXT DEFAULT NULL;
117
118ALTER TABLE afe_jobs
119ADD COLUMN parameterized_job_id INT DEFAULT NULL;
120
121ALTER TABLE afe_jobs
122ADD CONSTRAINT afe_jobs_parameterized_job_ibfk
123FOREIGN KEY (parameterized_job_id) REFERENCES afe_parameterized_jobs (id);
124"""
125
126
127DOWN_SQL = """
128ALTER TABLE afe_jobs
129DROP FOREIGN KEY afe_jobs_parameterized_job_ibfk;
130
131ALTER TABLE afe_jobs
132DROP COLUMN parameterized_job_id;
133
134ALTER TABLE afe_jobs
135MODIFY COLUMN control_file TEXT;
136
137DROP TABLE afe_parameterized_job_parameters;
138DROP TABLE afe_parameterized_job_profiler_parameters;
139DROP TABLE afe_parameterized_jobs_profilers;
140DROP TABLE afe_parameterized_jobs_kernels;
141DROP TABLE afe_kernels;
142DROP TABLE afe_parameterized_jobs;
143DROP TABLE afe_test_parameters;
144"""
145