Fixed #21852 -- Make migration writer serialize iterators