• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1def migrate_up(manager):
2    manager.execute_script(ADD_COLUMNS_SQL)
3    manager.execute_script(ALTER_VIEWS_UP_SQL)
4
5
6def migrate_down(manager):
7    manager.execute_script(DROP_COLUMNS_SQL)
8    manager.execute_script(ALTER_VIEWS_DOWN_SQL)
9
10
11ADD_COLUMNS_SQL = """\
12ALTER TABLE jobs ADD COLUMN queued_time datetime NULL;
13ALTER TABLE jobs ADD COLUMN started_time datetime NULL;
14ALTER TABLE jobs ADD COLUMN finished_time datetime NULL;
15"""
16
17
18DROP_COLUMNS_SQL = """\
19ALTER TABLE jobs DROP queued_time, DROP started_time, DROP finished_time;
20"""
21
22
23ALTER_VIEWS_UP_SQL = """\
24ALTER VIEW test_view AS
25SELECT  tests.test_idx,
26        tests.job_idx,
27        tests.test,
28        tests.subdir,
29        tests.kernel_idx,
30        tests.status,
31        tests.reason,
32        tests.machine_idx,
33        jobs.tag AS job_tag,
34        jobs.label AS job_label,
35        jobs.username AS job_username,
36        jobs.queued_time AS job_queued_time,
37        jobs.started_time AS job_started_time,
38        jobs.finished_time AS job_finished_time,
39        machines.hostname AS machine_hostname,
40        machines.machine_group,
41        machines.owner AS machine_owner,
42        kernels.kernel_hash,
43        kernels.base AS kernel_base,
44        kernels.printable AS kernel_printable,
45        status.word AS status_word
46FROM tests
47INNER JOIN jobs ON jobs.job_idx = tests.job_idx
48INNER JOIN machines ON machines.machine_idx = jobs.machine_idx
49INNER JOIN kernels ON kernels.kernel_idx = tests.kernel_idx
50INNER JOIN status ON status.status_idx = tests.status;
51
52-- perf_view (to make life easier for people trying to mine performance data)
53ALTER VIEW perf_view AS
54SELECT  tests.test_idx,
55        tests.job_idx,
56        tests.test,
57        tests.subdir,
58        tests.kernel_idx,
59        tests.status,
60        tests.reason,
61        tests.machine_idx,
62        jobs.tag AS job_tag,
63        jobs.label AS job_label,
64        jobs.username AS job_username,
65        jobs.queued_time AS job_queued_time,
66        jobs.started_time AS job_started_time,
67        jobs.finished_time AS job_finished_time,
68        machines.hostname AS machine_hostname,
69        machines.machine_group,
70        machines.owner AS machine_owner,
71        kernels.kernel_hash,
72        kernels.base AS kernel_base,
73        kernels.printable AS kernel_printable,
74        status.word AS status_word,
75        iteration_result.iteration,
76        iteration_result.attribute AS iteration_key,
77        iteration_result.value AS iteration_value
78FROM tests
79INNER JOIN jobs ON jobs.job_idx = tests.job_idx
80INNER JOIN machines ON machines.machine_idx = jobs.machine_idx
81INNER JOIN kernels ON kernels.kernel_idx = tests.kernel_idx
82INNER JOIN status ON status.status_idx = tests.status
83INNER JOIN iteration_result ON iteration_result.test_idx = tests.kernel_idx;
84"""
85
86
87ALTER_VIEWS_DOWN_SQL = """\
88ALTER VIEW test_view AS
89SELECT  tests.test_idx,
90        tests.job_idx,
91        tests.test,
92        tests.subdir,
93        tests.kernel_idx,
94        tests.status,
95        tests.reason,
96        tests.machine_idx,
97        jobs.tag AS job_tag,
98        jobs.label AS job_label,
99        jobs.username AS job_username,
100        machines.hostname AS machine_hostname,
101        machines.machine_group,
102        machines.owner AS machine_owner,
103        kernels.kernel_hash,
104        kernels.base AS kernel_base,
105        kernels.printable AS kernel_printable,
106        status.word AS status_word
107FROM tests
108INNER JOIN jobs ON jobs.job_idx = tests.job_idx
109INNER JOIN machines ON machines.machine_idx = jobs.machine_idx
110INNER JOIN kernels ON kernels.kernel_idx = tests.kernel_idx
111INNER JOIN status ON status.status_idx = tests.status;
112
113-- perf_view (to make life easier for people trying to mine performance data)
114ALTER VIEW perf_view AS
115SELECT  tests.test_idx,
116        tests.job_idx,
117        tests.test,
118        tests.subdir,
119        tests.kernel_idx,
120        tests.status,
121        tests.reason,
122        tests.machine_idx,
123        jobs.tag AS job_tag,
124        jobs.label AS job_label,
125        jobs.username AS job_username,
126        machines.hostname AS machine_hostname,
127        machines.machine_group,
128        machines.owner AS machine_owner,
129        kernels.kernel_hash,
130        kernels.base AS kernel_base,
131        kernels.printable AS kernel_printable,
132        status.word AS status_word,
133        iteration_result.iteration,
134        iteration_result.attribute AS iteration_key,
135        iteration_result.value AS iteration_value
136FROM tests
137INNER JOIN jobs ON jobs.job_idx = tests.job_idx
138INNER JOIN machines ON machines.machine_idx = jobs.machine_idx
139INNER JOIN kernels ON kernels.kernel_idx = tests.kernel_idx
140INNER JOIN status ON status.status_idx = tests.status
141INNER JOIN iteration_result ON iteration_result.test_idx = tests.kernel_idx;
142"""
143