-
-
Save ecarreras/e3f3695721ddeb669f854dc99ca49002 to your computer and use it in GitHub Desktop.
Consultar i eliminar workflows duplicats
This file contains 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
delete from wkf_workitem where id in (select min(wkd.id) from wkf_workitem wkd where wkd.inst_id in (select | |
inst_id | |
from | |
wkf_workitem wki | |
JOIN wkf_instance ins ON ins.id = wki.inst_id | |
group by | |
inst_id, ins.res_id, ins.res_type, ins.uid | |
having | |
count(*) > 1 | |
) and wkd.state = 'complete' group by wkd.inst_id order by wkd.inst_id); |
This file contains 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
select | |
ins.res_id, ins.res_type, count(*), array_agg(wki.id) | |
from | |
wkf_workitem wki | |
JOIN wkf_instance ins ON ins.id = wki.inst_id | |
group by | |
ins.res_id, ins.res_type | |
having | |
count(*) > 1 | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment