Move postgres code to dw