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