Move migrations queries out of post*