2

I have to migrate 9000 users (name, address, email, tel, photo...) from a non-drupal-site into a new drupal7-site.

How can I programmatically mimic the registration process and push the data in corresponding fields? And is there a way to change the original password, stored as a MD5-hash, to the drupal7-format while processing the data?

Thanks!

5

Take a look at the Migrate module. From the project page:

The migrate module provides a flexible framework for migrating content into Drupal from other sources (e.g., when converting a web site from another CMS to Drupal). Out-of-the-box, support for creating core Drupal objects such as nodes, users, and comments is included - it can easily be extended for migrating other kinds of content. Content is imported and rolled back using Drush commands.

1

I have used migrate the last 2 weeks, it's probably the most robust way to import lots of data and do data manipulation during import.

The problem is that it doesn't have a nice UI, you have to setup the migration in code. The included examples are great, but if you are not comfortable with PHP code you might want to try out feeds module instead.

  • I had a look at the migration-module. It is a powerful module bud not easy to understand for me. I'm planing to migrate the user-data first and the the profile-data (ie. name, address, photo...) in a second step (the profile-data are referenced by the uid). Or is it possible to import all data in one step? – uvo Feb 24 '12 at 11:03
  • are you using profile2? If not you migrate them at the same time, just take a look at the beer.inc example and how they map field_migrate_example_gender – uwe Feb 24 '12 at 15:00
  • Fortunately I'm not using profile2. At the moment I try to get a simple import working. I found an example (goo.gl/Bt7dH) bud I allways get the error: SQLSTATE[HY000]: General error: 1364 Field 'userid' doesn't have a default value. – uvo Feb 26 '12 at 20:23
  • use the beer.inc example, it's documented really well. Give it a few hours to get really familiar with migrate, it's not a simple module but can do a lot once you got it working ;-) – uwe Feb 26 '12 at 20:37
  • 1
    It took some time... bud now i have all users imported using the migrate-module. thank you for the help and the encouragement! – uvo Mar 1 '12 at 8:02
0

If your data is in another MySQL table you can write a simple "SELECT" statement in MySQL Workbench like so:

SELECT 
  a.`name` as `name`,
  a.`password` as `pass`,
  a.`email` as `mail`,
  .....
  1 as `status`,
FROM 
  my_old_users_table a

The first value in the select is the field in your old table, and the value after the word "as" is the corresponding field in the drupal users table.

For default values, just select a literal value: 'default@email.com' as mail

You then export that resultset as "SQL Insert statements" and then dump them into your users table.

I've never done this with Drupal tables before and I don't know the implications (effects on other tables), but I've done this previously to import masses of data from an ASP website into Wordpress posts table and it seems to work well.

Hope this helps, good luck

  • This method breaks down if you have modules enabled which declare any of the user module hooks (hook_user_insert, hook_user_presave, etc), that do their own thing. – mpdonadio Feb 23 '12 at 18:05
  • You're absolutely right, hadn't thought of that. I'll keep that in mind, thanks. – Beebee Feb 24 '12 at 9:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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