code: func MigrateWALs(ctx context.Context, oldDir, newDir string, oldFactory, newFactory WALFactory, snapshot walpb.Snapshot) error {
  	oldReader, waldata, err := ReadRepairWAL(ctx, oldDir, snapshot, oldFactory)
  	if err != nil {
  		return err
  	}
  	oldReader.Close()
  
  	if err := os.MkdirAll(filepath.Dir(newDir), 0700); err != nil {
  		return errors.Wrap(err, "could not create parent directory")
  	}
  
  	// keep temporary wal directory so WAL initialization appears atomic
  	tmpdirpath := filepath.Clean(newDir) + ".tmp"
  	if err := os.RemoveAll(tmpdirpath); err != nil {
  		return errors.Wrap(err, "could not remove temporary WAL directory")
  	}
  	defer os.RemoveAll(tmpdirpath)
  
  	tmpWAL, err := newFactory.Create(tmpdirpath, waldata.Metadata)
  	if err != nil {
  		return errors.Wrap(err, "could not create new WAL in temporary WAL directory")
  	}
  	defer tmpWAL.Close()
  
  	if err := tmpWAL.SaveSnapshot(snapshot); err != nil {
  		return errors.Wrap(err, "could not write WAL snapshot in temporary directory")
  	}
  
  	if err := tmpWAL.Save(waldata.HardState, waldata.Entries); err != nil {
  		return errors.Wrap(err, "could not migrate WALs to temporary directory")
  	}
  	if err := tmpWAL.Close(); err != nil {
  		return err
  	}
  
  	return os.Rename(tmpdirpath, newDir)
  }
docs: // MigrateWALs reads existing WALs (from a particular snapshot and beyond) from one directory, encoded one way,
  // and writes them to a new directory, encoded a different way