Migrate to node content type with the right user id (migrate module) I want to migrate an old website (not Drupal) into Drupal.
I want to migrate a table to a specific content type...

Inside that table there are many fields in addition to the user_id field,
so every record has 'field_1', 'field_2', ..., 'field_n' and 'user_id' field (foreign key of table "users")

First I successfully migrated "users" table. The problem is that 'user_id' ( of old website) is not the same as 'uid' of the Drupal website.
For example assuming that the first record will be migrated, has the 'user_id' = 255. This user is already inserted with the 'uid' = 55 inside Drupal. Now I want to insert the node with the correct uid (witch is 55), but inside the table I have 255.

How can I do the correct mapping inside the Migrate class to insert every record inside "node" table with the correct 'uid' ?
Or if there is another solution to do it "All in one" (create users and the nodes at the same time) maybe Migrate module has some powerfull functionality like creating a temporary database table that tell the migrate classes that the uid 55 is the same as the user_id 255 of the old website... 

Thanks in advance.
You use the sourceMigration() method of the migrate module. You should:

1) Write one migration to migrate old users to the new version of drupal.
2) Then write a migration that moves an old table to the new version of drupal.

In (2) when you setup your field migration it sounds like you've written:

# Field Mappings Docs: https://www.drupal.org/node/1133448
# this maps new &lt;= old field.
$this-&gt;addFieldMapping('new_user_id_field', 'old_user_id_field');


When you want to write:

# Search for sourceMigration on this page:
# https://www.drupal.org/node/1133448
$this-&gt;addFieldMapping('new_user_id_field', 'old_user_id_field')-&gt;sourceMigration('MigrateLegacyUsers');


This then uses a previously run MigrateLegacyUsers migration I described in (1) as the lookup for the new user ID in the new drupal site from the mapping table stored by Migrate for the old_user_id_field created during the MigrateLegacyUsers migration task.

Also note if you possibly have multiple users migrated into the system, say from a drupal legacy system, a wordpress system or LDAP you could write:

`-&gt;sourceMigration(array('MigrateLegacyUsers', 'MigrateWordressUsers', 'MigrateLDAPUsers'));`


This means: Find the legacy user id among all these possible prior migrations of Users. The first user_id that matches the requested legacy ID will be used by migrate (so be careful to assure all the user_ids are unique across multiple sources).