Update replicate script to work with pgsql 9.3