Assign previous migration destination id in prepareRow Working on migration of 6 to 7 where 2 websites are being merged into one. This is being done using migrate module.

There are duplicate users in 2 source sites and intended result is that the user that exists from the 1st migration should be linked as destination id on the second without being updated. 

We already have migrations set up for 2 sites and site #1 is imported.  When importing users from site #2 we want to essentially keep the same user from site #1 and link all content from site #2 to be owned by user from #1. 

Can this be done in prepareRow and how ?
In your site 2 content (Node) migration you probably want to use the prepare() function.


  function prepare($entity, stdClass $row)
  
  The Migration class prepare()
  method is called by the destination class prepare() method, after it
  has called all field-level prepare() methods and immediately before
  the destination object is saved. The $entity argument is the
  destination object as populated by the initial field mappings and
  manipulated by the field-level methods; the $row argument is an object
  containing the data after prepareRow() and any callbacks have been
  applied. The prepare() method is the last chance to manipulate the
  destination object before it is saved to the Drupal database. It is
  important to remember that, since it is called after the field
  handlers, fields will be in their fully-expanded forms (i.e., in
  Drupal 7 a text field value will be at
  $entity->field_textual_data['und'][0]['value'] rather than simply
  $entity->field_textual_data).


Within your Migration prepare function you want to set the UID of the content to whoever you want to be the creator of that piece of data.

As an example:

public function prepare($entity, stdClass $row) {
  $query = /* Query to figure out UID from site 1, from a UID in site 2 ... for current node NID*/;
  $desired_uid = db_query($query);
  $entity-&gt;uid = $desired_uid;
}