pg-ify multi-table deletes

(cherry picked from commit a51c1b39e613419669e739e70cd788d86f3d5137)
put brackets in the right place, genius

(cherry picked from commit 99acccbd60a3c7b2934e23fbaa4770908f0a5fff)
cast times

(cherry picked from commit b33aedb602ecb71d3f2f665f7731da55e71b6c46)