fixed db rebuild for pgs