Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ecarreras/e3f3695721ddeb669f854dc99ca49002 to your computer and use it in GitHub Desktop.
Save ecarreras/e3f3695721ddeb669f854dc99ca49002 to your computer and use it in GitHub Desktop.
Consultar i eliminar workflows duplicats
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);
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