I'm trying to migrate a Drupal 6 site to a totally new implementation of Drupal 7.

I'm using the migrate module, and I am able to successfully migrate users and passwords, as well as their roles, but the users UIDs is not being maintained.

I believe that the issue is that UIDs must be explicitly set on the user object before saving it, and migrate is not doing that for me.


Any tips on how I can do that? I need my UIDs on Drupal 7 to be exactly the same as Drupal 6!

2 Answers 2


For migrating to Drupal 7, it's much simpler:

// Pass the old uid through
$this->addFieldMapping('uid', 'uid');
// Tell user_save to create a new account with the given uid (otherwise it sees the
// uid and assumes you're updating an account).
  • This is the correct answer.
    – Fidelix
    Jun 18, 2013 at 18:43

Cribbing from this

  1. Delete the original UID column in the destination users table
  2. Create a new UID column (w/o primary and auto increment settings)
  3. Map the source UID to the UID column
  4. Perform the import
  5. Add primary and auto increment settings to the UID column

If you need UIDs to be the same there is a chance that you are misusing them. There are a few cases where it matters (theme overrides perhaps) but in most cases it shouldn't matter.

  • I need UIDs to be the same so I can synchronize all modules correctly (Private messages, Nodes, Flags, etc...). Will matching UIDs be "discovered" somehow by Migrate?
    – Fidelix
    Jun 30, 2011 at 12:02
  • Have a look at drupal.org/project/migrate_extras to see what is supported. Jun 30, 2011 at 12:51
  • Alright, but do you know if these migrate_extras supported features will recognize the old and new UIDs automatically, so I don't end with messed up entries?
    – Fidelix
    Jun 30, 2011 at 13:41
  • And I REALLY need the UIDs to be the same, because I will integrate OpenAtrium with D7, and I already have hundreds of nodes on OA.
    – Fidelix
    Jun 30, 2011 at 14:12
  • Then the above should work for you. Jun 30, 2011 at 14:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.