Last active
August 29, 2015 13:58
-
-
Save milimetric/9942357 to your computer and use it in GitHub Desktop.
updates the old report table results to make them work with the new UI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
begin; | |
/* insert a RunReport for each AggregateReport, easiest way is to delete existing ones first */ | |
delete from report where name like '<RunReport("%'; | |
insert into report (name, show_in_ui, queue_result_key, result_key, created, user_id, status, parameters) | |
select 'RunReport Will Rename Below' as name, | |
0 as show_in_ui, | |
a.queue_result_key, | |
a.result_key, | |
a.created, | |
a.user_id, | |
a.status, | |
a.parameters | |
from report a | |
where show_in_ui=1 | |
and result_key is not null | |
; | |
/* transfer the show_in_ui and queue_result_key from AggregateReport to RunReport, also rename properly */ | |
update report r | |
inner join | |
(select name, queue_result_key, result_key, show_in_ui | |
from report | |
where show_in_ui=1 | |
and result_key is not null) u on u.queue_result_key = r.queue_result_key | |
and (r.name=u.name or r.result_key=u.result_key) | |
set r.name = case | |
when r.name like 'RunReport Will Rename Below' and r.result_key=u.result_key then u.name | |
when r.show_in_ui=1 then concat('<AggregateReport("', r.id, '")>') | |
when r.show_in_ui=0 then concat('<MultiProjectMetricReport("', r.id, '")>') | |
else 'Should Never Happen, Check for this string after updating' | |
end, | |
r.result_key = u.result_key, | |
r.show_in_ui = case | |
when r.name like 'RunReport Will Rename Below' then 1 | |
else 0 | |
end | |
; | |
commit; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment